« first day (586 days earlier)      last day (4360 days later) » 

11:01 PM
Do not loop while good(). (That question title mentions eof, but the same issue is here: the check is before the input). — R. Martinho Fernandes 20 secs ago
That's the second time I link to that today.
 
People y u suggest using namespace std;.
People y u no suggest if (file).
 
@RadekdaknokSlupik I've never had to put the parenthesis around the second argument like you did. You positive the most vexing parse kicks in there?
 
@MooingDuck I posted the answer while on my iPod so I couldn't test it.
 
ideone is blocked on iPods?
 
@RadekdaknokSlupik iPod or iPad?
 
11:07 PM
iPod touch
@RMartinhoFernandes too lazy am I.
Feel free to remove the parentheses if you feel like it. They can't harm, though.
 
Why would looping with push_back be less efficient than using the iterators?
 
Some dude said that in a comment.
 
Here's a secret: the vector constructor will have the same loop.
 
I'm revising my answer. Brb.
 
@RMartinhoFernandes Because the vector constructor will have a dispatcher that will resize in advance and then probably skip resize checking if the iterators are random access
 
11:09 PM
@DeadMG Those are stream iterators.
 
@RMartinhoFernandes ah ok
 
@RMartinhoFernandes Would you say the same exact complexity has been moved into that constructor?
 
What do you mean by "complexity"? I'm pretty sure it has the same time complexity.
Did you mean some other one?
 
In the general sense that software has complexity. Not in the algorithmic sense.
 
11:16 PM
damnit
 
Bad luck Radek.
 
my code is non-working and I have no idea why
 
Posts answer.
OP has 0% accept rate.
@DeadMG because it has a bug.
 
@LucDanton Well, not exact then. Some of it goes in the iterators.
 
got that far :P
 
11:18 PM
:P
 
The vector is ignorant of streams, while the manual loop would deal directly with them.
 
Can't it use std::distance?
 
@RadekdaknokSlupik Not on input iterators
 
Or wait that obviously doesn't work on istreambuf_iterators.
 
@RMartinhoFernandes Good point.
 
11:20 PM
Never thought I would say this.
Comment y u no onebox!!1
 
Seriously, there's #include <vector> in the question...
Something's borken.
 
@RMartinhoFernandes What's going on?
 
@LucDanton Someone posted an answer suggesting an array, assuming that since it was homework, std::vector was not allowed.
 
And he introduced a buffer overflow.
 
Well, maybe it's not!
 
11:23 PM
Congratulations, you got a buffer overflow in C++.
 
@LucDanton The question has #include <vector>!
 
I think I'm holding onto that thought because thinking of someone that goes out of its way to use std::vector when they might have been told not to makes me feel fuzzy.
 
@DeadMG +1
xD genius.
 
@RadekdaknokSlupik I'm -1ing your answer. Not enough boost.
:P
 
@RadekdaknokSlupik :what is the istreambuf_iterator ? is it by default ? istreambuf_iterator<char>(file)
 
11:27 PM
My answer shouldn't be accepted; it doesn't mention jQuery.
@prjndhi default constructor constructs an end iterator.
 
Output stream iterators suck btw.
 
that means it iterate over file .
 
@Martinho What's their point?
 
not need to loop.
 
fuck
I'mma go to sleep
night nubs
 
11:29 PM
@RadekdaknokSlupik Using std::copy and the likes to perform output.
 
sleep hard
@RMartinhoFernandes meh.
That's confusing people.
 
@RMartinhoFernandes In what way?
 
@LucDanton Well, they're only useful for outputting one item per line.
If you want space-separated or comma-separated or whatnot, you get an extra separator at the end.
 
They're useful for outputting stuff without separators as well!
 
Hm, yeah, that too. Doesn't come up very often, though.
 
11:34 PM
@RMartinhoFernandes I'm pretty sure the ostream iterators take a seperator string
 
@MooingDuck Yes. And you get one at the end. That's my peeve.
 
@RMartinhoFernandes ah
 
I want parsers to accept trailing commas (yay for C++11), but I don't want them in my output.
 
std::copy(b, std::prev(e), out); *out = *std::prev(e); looks silly.
 
11:36 PM
@RadekdaknokSlupik Poor sod.
 
Bad luck pachun.
He must be happy. He learned about buffer overflows and VLAs today.
Hmm, knowing about VLAs and being happy…
TIL: valgrind uses JIT compilation.
 
Oh ya and my previous snippet is wrong for empty ranges. Figures.
 
11:51 PM
@LucDanton Non-trailing commas are hard.
Well, not that hard. But impossible to get elegantly.
 

« first day (586 days earlier)      last day (4360 days later) »