« first day (982 days earlier)      last day (3959 days later) » 

9:00 AM
@Rapptz hm?
@Rapptz if (str.size() > 0) str.resize (str.size() - 2);
 
yeah now you have two loops instead of one (resize is O(N))
could just pop_back twice though
 
@Rapptz I believe that resizing to a smaller size is O(1)
or at least amortized O(1)
 
but O(n) is in the worst case, isn't it?
 
or why does it even matter
 
@gekannt Average case because it has to potentially reallocate and copy/move/etc everything I think.
 
9:02 AM
@Rapptz copying a POD can't be O(N)
it's just one memcpy
 
Uh.. looping over the container to copy everything is linear in the size of the container.
 
and inner string buffer is a POD alright
 
Average in what sense? What are you feeding to resize?
 
@Rapptz but you don't loop over a string to copy it :/
 
If you pass in the exact capacity of the container every time, then it's O(1) in average.
 
9:04 AM
Didn't his "not-" license expire already?
:P
 
@LucDanton We were talking about if count < capacity
But I was talking mostly for count > capacity
(count == capacity wasn't brought up)
 
for that it's still one copy, not one for every character.
 
Ye but that's very nebulous. How the capacity grows is very dependent on what you're doing.
 
(or is that Clippy impersonating sehe. Please advise. Thx)
 
Well, I just checked cppreference and it says that resize's complexity is "Linear in the size of the container"
 
9:06 AM
I picked 'pass in the exact capacity' as an outrageously contrived example on purpose. There's no general way to reason about capacity.
 
@BoltClock it's our sehe allright.
 
Good
 
@Rapptz for non-POD types
 
Xeo
@BoltClock He doesn't want to accept that. :(
 
@Rapptz Yes, but that's not useful in a larger context. E.g. the complexity of doing some insertions, then resize, might very well not be linear in the amortized case depending on what kind of data you pass in.
(And of course how much you resize: point being everything matters.)
 
9:08 AM
Okay.. then.
 
on the completely different topic
Does C# have concepts?
 
@Rapptz Saying 'the operation is linear' gives the impression it will always put a linear upper bound in complexity. Which is misleading.
 
JBL
Ugh stupid problem... It even feels too localized for an SO question... :(
 
Whatever, I still would have called pop_back twice.
 
hehe
hi @jalf
 
9:12 AM
hihi
 
@Rapptz Don't get peeved :( This kind of analysis is a staple when it comes to data structures and algorithms that operate on them.
 
@LightnessRacesinOrbit what?
 
@Rapptz If you want the type for something where you will store something it's Decay. Primary use cases for Unqualified are unwrapping a type for specializations, or for accessing nested types in it.
 
9:27 AM
21
A: The Many Memes of Meta

BoltClock's a UnicornMeme: Oscillation Originator: asdf_enel_hak First Heard: February 3rd, 2013 Cultural Height: Oscillates between then and now Definition: The repetitive variation, typically in time, of some measure about a central value (often a point of equilibrium) or between two or more different states (W...

 
JBL
Mmmh. Quick question : Is "A memory segment has been damaged" equivalent to heap corruption ?
 
@JBL Depends on context.
 
@JBL it's equivalent to sucking :F
 
JBL
@BartekBanachewicz Yeah, sure, this I'm aware of !
 
@JBL just break in the debugger and look at the call stack
 
JBL
9:28 AM
@BartekBanachewicz Done that, still can't understand what's happening...
 
most of such cases can be found more or less directly
@JBL where did it break?
 
JBL
Exact line is > std::_Allocate<short>(unsigned __int64 _Count, short * __formal) Line 28 C++
A vector which ends up with a memory problem..
I suspect a function to be responsible for messing up the vector, but can't figure out how to fix that.
 
@JBL full callstack
also free Ice cream at work today :3
 
JBL
Oh wait...
 
Xeo
46
Q: How to emulate C array initialization "int arr[] = { e1, e2, e3, ... }" behaviour with std::array?

Xeo(Note: This question is about not having to specify the number of elements and still allow nested types to be directly initialized.) This question discusses the uses left for a C array like int arr[20];. On his answer, @James Kanze shows one of the last strongholds of C arrays, it's unique initia...

 
JBL
9:32 AM
@BartekBanachewicz Yum !
 
@Xeo How come I didn't come across that earlier? My Google-fu fails me today.
 
@rubenvb Comparisons are just one thing. Does unsigned height = -1; get you warnings? It doesn't give you a negative height, but it gives you a ridiculous value that you have no way to tell apart from a legitimate one. (obviously that example is stripped down to the minimum; in real code it might be something like void f(unsigned); int g(); f(g());)
 
JBL
Gosh is my code that bad ? Trying to reproduce the error, it broke before...
Okay the error happens through an OpenAL function...
Which demands a void* for the array it fills... Blergh !
 
@R.MartinhoFernandes now that's type safety
 
JBL
9:38 AM
I guess it's quite wrong if my vector believes it has 372 elements, but the debugger shows me 800+ values...
 
debuggers lie
 
JBL
I just don't know what to trust anymore...
 
Xeo
@JBL Is the vector correctly resized before passing its data to that function?
 
@JBL not sure if it is your problem, but vector::size() is not the same as vector::capacity()
 
@R.MartinhoFernandes I like my foo(explicit unsigned i) idea :(
 
JBL
9:40 AM
@thecoshman It has in fact the same capacity as its size.
@thecoshman But inspecting it with VS debugger, it shows a size of 372, but VS shows me 800+ values in the Watch window.
@Xeo Yep.
 
JBL
buffer.resize(sampleCount);
alcCaptureSamples(m_audioDevice,buffer.data(), sampleCount);
 
@JBL yes, by maybe the 800+ is the capacity, whilst the 372 is the size. Size is how many elements are actually used. Capacity is how many elements the actual array that is allocated can hold before vector has to resize
 
@BartekBanachewicz There's no TMP you can do, so there is very little that you would find missing. where T : interface covers most things.
 
JBL
@thecoshman It shows 372 as capacity too.
And why does formatting as Code doesn't work... ?
 
9:42 AM
The only pain I have found is no ability to specify ctors other than the no-arg one.
 
@R.MartinhoFernandes it looks like a much easier language than C++ from what I've read and written in it
@R.MartinhoFernandes hm?
 
@BartekBanachewicz where T : new() requires new T() to be valid. But there is no way to require, e.g., new T(0). where T : new(int) is not allowed.
 
@R.MartinhoFernandes In bounds (if that's term)? I don't think I ever constrain on constructability in C++.
 
JBL
This feels horribly wrong ...
 
@BartekBanachewicz Checked arithmetic is a cool niche feature.
NodaTime compiles with /checked which is a compiler flag that makes it the default everywhere.
The only place where it uses unchecked is hashes.
 
9:47 AM
@JBL Uh.. 372 in hex is 882 in decimal.
 
@JBL 0x372 is 882.
 
@R.MartinhoFernandes I will compile my code with /checked frow now on too. Not that I really write much C#, but summer is coming.
 
JBL
@LucDanton Oh shit I'm an idiot.
12
Just...
I want a rope, right now.
 
@JBL at least you admit it :P
 
JBL
9:48 AM
@thecoshman There's no point justifying not to at this point...
 
@R.MartinhoFernandes well it's just our 'ole default_constructible, which use is probably dominant over exact constructor interface.
@JBL stl::rope?
 
JBL
@BartekBanachewicz Pretty much.
But then I'm clueless now...
3 stars for saying I'm an idiot. Doesn't know how to feel about this...
 
And the question is? — Rapptz 9 secs ago
 
@JBL Accepted.
 
JBL
Where's my green tick ?
 
9:51 AM
Sep 11 '12 at 13:04, by Xeo
@TonyTheLion We'll seize any and all opportunities to star self-deprecating messages.
 
JBL
@BartekBanachewicz Oh that makes sense then...
 
@R.MartinhoFernandes that is the question? :)
 
template_id const &&
WTF
 
Looking at the code now, I have no idea is going on.
 
9:54 AM
@R.MartinhoFernandes get_printing_template :p
 
It compiles. If you need int main() draw it in your mind. — John 1 min ago
 
JBL
@BartekBanachewicz What the....
Did the guy even tried to compile his code... ?
 
it looks like tried to mimic C++ code and mashed up random stuff
that's something monte carlo would produce :P
 
JBL
Okay, is there a good alternative to OpenAL.. ?
 
@LucDanton What does that mean?
 
9:59 AM
E.g. where to put the letterhead. Maybe.
 
Needs more close votes.
 
@JBL SFML and Fmod, both high-level though
 
> The question is in the title.
Is the guy drunk?
 
JBL
@BartekBanachewicz I'm looking into FMOD atm. Didn't think of SFML though, thanks.
I mean, what do you expect from a function that takes a void* as buffer, and the doc doesn't detail correctly what the buffer should be...
 
GL_UNSIGNED_SHORT_5_5_5_1
kill me
 
JBL
10:06 AM
5 red, 5 blue, 5 green, 1 alpha ?
 
don't ask questions - just kill him
 
JBL
It feels a bit short.
 
Or 1 throwaway. One bit doesn't really get you much blending.
 
-2
Q: Please give regular expression for my match

Mangesh NarayankarWhat should be the regular expression for getting string between "url(" and ")". Means i am having something like "url(abcd.gif)" and i just want "abcd.gif" which is in between "url(" and ")".

 
JBL
10:10 AM
@Potatoswatter There / Not there
Useful blending toi have.
 
@Potatoswatter it would be simply _5_5_5 then
 
Yeah. Masking. But often the bit is just not used.
 
JBL
@LightnessRacesinOrbit The guy who answered should be downvoted to hell..
 
also there's 5_6_5 format
 
10:12 AM
@BartekBanachewicz Really? That would fail to specify whether the high- or low-order bit is unused. I don't know the first thing about OpenGL, anyway.
 
Good afternoon
 
@ApprenticeHacker Good evening… read any good Donald Trump emails lately?
 
oh wait.
 
@Potatoswatter nah, who is he?
 
@LightnessRacesinOrbit lol, JavaScript forces you to use the primitive loop over integers for iterating over arrays?
 
JBL
10:15 AM
@BartekBanachewicz I still can't grasp the concept behind non-even bit distribution for colors... Is it just to fit in formats that don't divide by 3 ?
 
Strange, I didn't even log in for at least the past 6 months and ironically I gained more rep that when I used to regularly answer questions (i.e my repwhoring days).
 
@ApprenticeHacker The boss of the TV show, "The Apprentice"
 
@Potatoswatter Oh, I get it. lol.
 
@R.MartinhoFernandes It doesn't force you to, but arrays are dictionary-like collections, and the range-for style syntax would may in alphabetical order not numerical.
 
Damn, the A Levels have destroyed my sense of humour. -_-
 
10:16 AM
@JBL Eyes are more sensitive to green so it makes more sense to have more green bits.
 
JBL
@Potatoswatter Oh ok. Interesting.
 
@JBL what Potato said
 
-3
Q: Encoding characters from pdf

user2514644I'm reading a pdf file with C#. But the characters are coming from another encoding. Return different characters. My code string file = @"c:\document.pdf"; Stream stream = File.Open(file, FileMode.Open); BinaryReader binaryReady = new BinaryReader(stream); byte[]...

lol
 
@R.MartinhoFernandes haha
 
"I am reading a PDF as a blob of text and it doesn't work. Characters are coming from another encoding. Return different characters."
 
10:18 AM
@R.MartinhoFernandes return his characters!
 
@R.MartinhoFernandes Needs more fairy dust.
 
@ScottW Hey Mr. Potatohead!
 
arghh, it's so hot!
I'm sweating even in an air conditioned room
Damn the Middle East. -_-
 
JBL
@R.MartinhoFernandes I like the "fully implement the large and complex details of how the file format works" answer.
 
10:21 AM
you have bad AC
 
JBL
I bet he wasn't expecting that.
 
@BartekBanachewicz Nah. I've tried three different ACs. I even tried sitting in my dad's car and using the car's AC. All of them can't be bad.
It's the blasted heat...
 
is <stdexcept> C++11?
 
@JBL I know that even Adobe doesn't.
 
10:24 AM
@TonyTheLion lol
 
@BartekBanachewicz old as rocks
 
@TonyTheLion It's your birthday?
 
@ApprenticeHacker Yesturday it was
 
@Potatoswatter good
 
@TonyTheLion Happy belated birthday, then.
2
 
10:26 AM
@ApprenticeHacker Thanks :)
 
I was reading tesla's biography, I thought to myself: would it be awesome, if, instead of radio frequency, my phone can send out laser and be used as a weapon?
 
@Telkitty猫咪咪 Microwave radiation is a lot closer to what the cell already produces, and can also make an effective weapon.
But Tesla would never do that, he didn't ever work on weapons.
 
@Potatoswatter good idea! ... and since it is of lower frequency it would use less energy!
 
@Telkitty猫咪咪 Nah, the amount of energy required to do damage is more or less constant.
 
0
Q: "Access violation error" in C++

user2515780I'm writing a class that adds a bunch of strings and then the user can chose to delete one of the strings. The problem is, every time I enter more than two strings and then attempt to delete one of them, my program crashes and I get this error: An access violation ( segmentation fault) raised i...

terrible
 
10:30 AM
@BartekBanachewicz seriously? you think C++ didn't have exceptions before C++11?
 
@ScottW hahah
Please go home and never write code again. — Tony The Lion 6 secs ago
 
@LightnessRacesinOrbit exceptions mechanism != standard exception types
 
Microwave range => deep heating, visible range => surface heating, higher => cell damage.
 
@TonyTheLion class DynamicStringArray stopped reading.
 
My laptop just randomly hangs and restarts at times
 
10:32 AM
@Potatoswatter I have never tried so I do not know ...
 
I don't know what the problem is. -_-
 
@R.MartinhoFernandes witness my comment
 
Ironically, my brain does the same thing.
 
10:33 AM
sehe
@ScottW I hope so. Then I can hopefully release myself from the horrors of programming once and for all. Oh wait... I have a dev job. Meh
@ScottW <3
 
@ScottW You get banned for giving good advice?
 
@ScottW I wish.
heh
same here, I'm stuck with it
-1
Q: C++ Undefined behaviour with unions

sklnWas just reading about some anonymous structures and how it is isn't standard and some general use case for it is undefined behaviour... This is the basic case: struct Point { union { struct { float x, y; }; float v[2]; }; }; So writing to x and then re...

kill it with fire!
 
@Potatoswatter that's because microwave can be used to quickly heat up water and cells are made mainly of water
Tesla worked with electromagnetic waves of all frequencies ... including laser and x-rays
 
@CatPlusPlus nice moustache.
@Potatoswatter The frequency of microwaves is almost equal to the frequency of the vibrations in water molecules. So it can be used to heat only things that contain water. It creates resonance
 
@Telkitty猫咪咪 FTR I just flagged this as rude too: stackoverflow.com/questions/17248462/… - and why don't you not invite certain factions into the lounge?
Or, you know, create a room for people that like chaotic street rumble, apparently including you.
 
10:42 AM
@Telkitty猫咪咪 I thought lasers were discovered after Tesla's time?
 
@not-sehe Thought you lot had 'lovely' times just now
rambling as usual
 
@not-sehe he actually came here
 
@BartekBanachewicz I don't wanna know, really
 
According to wikipedia, the first working laser was created in 1957 by Charles Hard Townes and Arthur Leonard Schawlow at Bell Labs. Tesla died long before then.
 
@not-sehe C master race.
 
10:45 AM
@ApprenticeHacker it was invented during his times, although might not by him
 
@Telkitty猫咪咪 I see.
 
most probably not ... because he would be around 80 by then
 
@BartekBanachewicz stackoverflow.com/questions/17248462/… (I didn't quote it! Just linked)
 
oh well, since he's very good at bluff, we might never know whether it is true
 
10:49 AM
@Telkitty猫咪咪 yeah, I guess. He wasn't very public about his discoveries and experiments.
 
best answer ever
11
A: virtual inheritance

OJ.Have a read of this (it's been asked before).

 
Why no dupe votes.
 
I fixed my answer. There was a superfluous newline in my code. I removed it.
 
@BartekBanachewicz Shouldn't the question be closed as a possible duplicate?
 
@ApprenticeHacker it should
@raxman it's still equally bad. You didn't answer me what would happen if op changed that to array of structs (which, coming from python, he might well do).
 
10:52 AM
@not-sehe damage is done and now he's not leaving
 
You know, I haven't been through every single chat room / community on the web. But frankly, after touring some of them briefly, I think this is perhaps the best chat room on the web.
 
@ApprenticeHacker yeah, we're the best room ever.
 
@ApprenticeHacker others have said the same
 
in a sarcastic way
 
Is fileformat.info down?
 
10:53 AM
@Telkitty猫咪咪 YOU get to decide this now? LOL
 
Why is she still around, btw?
 
@BartekBanachewicz You think C++ didn't have standard exception types before C++11?
 
JBL
I've lost all hopes, but why not :
0
Q: Memory corruption when capturing audio with OpenAL

JBLSo I'm trying to capture audio data with OpenAL, and then send it through Qt Signals and Slots system to another object using the following code (inspired from this post) : void AudioRecorder::startAudioCapture() { ALint sampleCount; std::vector<short> buffer; alcCaptureStart(m_audi...

 
@ApprenticeHacker Soon gonna be over
 
@LightnessRacesinOrbit Now I know it did, c'mon.
 
10:54 AM
The rest are just filled with idiots, retards, perverts, otakus, racists, sexists and extremely stupid and violent people.
 
@ApprenticeHacker ... The ape would say something about "when everybody is driving the other direction" ...
 
@not-sehe why
 
yeah, we don't have otakus here.
 
@BartekBanachewicz Where did you think they lived?
 
@LightnessRacesinOrbit under your bed.
 
10:55 AM
@BartekBanachewicz okay
 
@ApprenticeHacker Because Nostradamus couldn't make it, I'm filling in. I cheat: I just told you what I observed instead of actual prophesies
 
@LightnessRacesinOrbit they might have just forgotten them earlier, like make_unique
I was aware of pre-C++11 std::exception, but not the others
 
Don't use the others.
 
@R.MartinhoFernandes what
 
Inherit virtually from std::exception and boost::exception and use that.
 
10:57 AM
Is std::runtime_error suddenly bad?
 
@BartekBanachewicz weirdo
 
Throwing std::runtime_exception is acceptable for quick testing, but that's all.
 
@BartekBanachewicz no
@R.MartinhoFernandes what?
@R.MartinhoFernandes no because you're not allowed to add symbols into namespace std
 
@R.MartinhoFernandes Good (mandatory) reading here: boost.org/community/error_handling.html
 
@LightnessRacesinOrbit pedantry strikes again :D
 
10:59 AM
@BartekBanachewicz the difference between std::runtime_exception and std::runtime_error goes far beyond mere pedantry, friend.
 
> Actually, clang-format has been released in Clang 3.3 with a vim/emacs integration.
> It seems to works well, but the problem is that no customization of the style is possible, there are only predefined styles.
 

« first day (982 days earlier)      last day (3959 days later) »