« first day (589 days earlier)      last day (4344 days later) » 

12:00 AM
Yes, it will end up being a member variable, good for it. But how do I know what to initialize it with ^^ ?
 
Initialize?
 
Well, ok. Here's what I see:
Hello lambda. You will get an argument y of type integer, please send it to the cout stream.

Hello foreach, loop trough this array and apply lambda on each element in order.

Where exactly do I state that the "int y" for the lambda is the actual element ? (dereferenced iterator if you so wish)
 
The lambda overrides void operator()(int y).
 
I could write an equivalent function object
 
The lambda itself is not aware where y came from.
 
12:03 AM
Yes, the lambda is not the problem. How does foreach know what value to pass into that y ?
 
I always takes a lambda that takes one argument, and it passes *iterator to it.
 
But WHY does it pass *it to it :D ?
Who told it to :D ?
 
Because the standard says what for_each must do, and this is the most trivial implementation.
 
o_O It does ? :D
Thanks! :D
And if i had two arguments there, [](int y, int z) then the y would be the *it ?
 
It would not compile.
for_each takes a function that takes one argument of type decltype(*begin), or a reference to that.
 
12:05 AM
So actually, for_each is expecting a function with a signature that has exactly one parameter ?
yeaaaah
riight
thanks
 
Yup. No problem.
 
Dat sneaky foreach.
I was considering a premise that I could pass any lambda. Didn't realize that it could actually put a constraint on the signature of the callback function.
 
It does that implicitly by calling the callback.
template<class F> void foo(F callback) { callback(42); } must take a function that has the signature T(U), where T can be void or any type complete type, and U can be int or any type implicitly convertible from int.
 
@RadekdaknokSlupik Yarr that's simple. I was living in a world where I was telling to myself that I can literally pass "any std::function-kind-of-thing" if you know what I mean :)
Anyway, thanks again.
Big help ;)
 
If that would be true, what would happen if you passed a lambda that took no arguments to for_each? Would it order you a pizza?
Anal demons.
 
12:14 AM
Yeah, again, i somehow didn't realize it could impose constraints on the signature.
 
Cardional demons.
 
Otorhinolaringo demons ?
 
Me.
I'm a demon. You can tell from my avatar, which is a picture of my left eyeball.
I'm listening to emo music. Relevant xD
Anyone here played SCP-087-B? That game scared the hell out of me.
Which song?
 
@RadekdaknokSlupik Im gonna check the game on youtube :P
 
Hmm that's not my kind of music. :(
@Scarlet just play it :P it's free.
 
12:19 AM
@RadekdaknokSlupik I don't watch horrors nor anything even remotely scary. I like rainbows and unicorns ... and butterflies.
@RadekdaknokSlupik (I'm also a gaint wuss.)
 
:P
@ScottW I never listened to any of them. xD
I prefer symphonic metal, folk metal, psychedelic rock and J-rock.
DeWolff are pretty awesome.
 
@RadekdaknokSlupik Srsly, i'd rather stab myself in an eye with a fork than to play that game. I also heard about Amnesia: something, not even touching that :)
 
what is j-rock
 
Amnesia is awesome.
@Alf Japanese rock music.
It's weird and the English is worse than that of the average SO user, but the music is awesome.
I'll find some good J-rock.
I had it.
Sorry I cannot onebox it; iPod.
@ScottW that's cool. I never used it though.
 
12:35 AM
farewell
bounce well
 
Später.
Hey Scarlet.
Don't you need to sleep.
 
Not really. I had this "era" once where I would sleep 3 hours / day for weeks straight.
 
Me too.
It's enough for me.
 
And I wouldn't feel tired really.
I was pretty ok.
 
12:41 AM
Try doing that chat filtering magic on me saying : " facepalm " :)
 
I'll try it with "fork in the eye".
 
That ain't too shabby! :)
Also it would so seem I fancy using different kinds of smiley faces with that.
Nice and dandy.
 
it's stabby, not shabby
 
I'm quite good at facepalming.
 
12:45 AM
yeah i saw that one today i believe
 
he's kinda like buggs bunny rly
It's an interesting thing to observe actually.
Frequency of wordchoices of people.
Then if you take a look at it summarized, you can be like: Fac me cocleario vomere!
 
If you can download the entire transcript you can analyze it and generate graphs for each user.
 
Yeah you can do whatever statistical analysis you want really.
 
Pie diagrams, with each piece being a word he/she ever said.
 
12:49 AM
Yarr yarr.
 
I guess it would take a long time and very much memory on an average machine to do that for the entire transcript. xD
 
Yeah, it's a large quantum of data.
I'm looking forward to being able to pay for some cloud service that would let me access an array of computers for some real performance.
possibly with some auto paralellization kind of thing similar to mapreduce
just specify the dataset and the operation and have it spread across the available horsepower
 
Ell
Hi guys
 
nite kids
 
Ell
Night
Hmm it is getting late.
Anyone suggest thought provoking music?
Anyone here?
 
Xeo
1:12 AM
Wtf. I post an answer and literally seconds after that it gets downvoted.
 
1:23 AM
@Xeo Sucks, doesn't it? I once just about quit SO entirely when that happened like twice in ten minutes or so. Not that big of a deal, but for some reason right then it just pissed me off...
 
Xeo
It pisses me off when there's not even a comment. This time might've been a misclick, though, since it was removed later on and seemingly turned into an upvote
I have already a constructor of the form : template<class T1, class T2> MyClass(T1 x, T2 y) and I want a specific constructor for iterators. But I dont know the syntax for declaring a generic iterator... — Vincent 2 mins ago
Oh dammit..
 
 
2 hours later…
3:15 AM
good evening
 
morning
it's morning
0
A: Forward Iterator C++ : for_each behavior

Cheers and hth. - Alf#include <assert.h> // assert #include <iterator> // std::forward_iterator #include <utility> // std::pair #include <stddef.h> // ptrdiff_t, size_t typedef size_t UnsignedSize; typedef ptrdiff_t Size; typedef Size Index; templat...

^ Hurray, I answered yet another question!
hm, i need coffee. or breakfast. or both.
 
user457812
3:31 AM
I recommend neither, it's clearly time for a full-course dinner.
 
3:55 AM
@sehe Yes, I'd love feedback :) All I had there before was simply a Markdown-ified version of the existing wiki page to test drive the publishing system, but now I just finished putting the first real post up (should be visible as soon as GitHub wakes up and realises the pages need rebuilding). As for the title... it was randomly suggested by GitHub as a repo name :S I thought it kinda works as a description of C++, so I left it.
 
i think, would be nice to just post such link instead of having me link-chasing instead of drinking coffee (which i think i need)
 
4:09 AM
Something's wrong. It should have updated shit already.
 
 
1 hour later…
5:13 AM
Oh, I had fucked up the syntax for code highlights. It's up now.
 
All the way to the end: goodie :-)
Now all that's needed is to wait for Visual C++ 12.0, perhaps it has both using and regained support for writing native Windows apps?
La la la
 
 
1 hour later…
6:38 AM
Just woke up, only 8 hours of sleep. No more.
 
sbi
6:51 AM
there's a very clear advantage in having exceeded your provider's flat rate alliance: you don't need to care anymore.
um, allowance
of course, now that I dare to come to the chat with nothing but a touch phone's keyboard, everyone's asleep :(
oh, there's an "edit last" feature even in the chat's mobile version. I guess that's only fair, now that they got us hooked to this
well, it seems this chatte is deade
 
it is very diffecult writing book when u cqn't spel
"alliance" → "allowance"
oh yeah, you saw that @sbi
 
Damn, this coffee simply isn't working.
 
i wonder if early music by nils lofgren is still available legally, or do i have to use private download?
 
A... Private... Download. :Đ
 
yup
1986: Code Of The Road, Live '85, Europe/Japan only (A&M)
^ I have or at least had that on vinyl
good stuff
 
7:07 AM
Two days until Max Payne 3. Good times!
youtube.com/watch?v=l7aLPFlJb9s Ah, where did these times go? So relaxing.
 
8:13 AM
lol, 41rpm
stackoverflow.com/questions/46586/goto-still-considered-harmful ; third response. I was always tought to avoid a goto, even if my life depended on it.
mind you
I see them having a use in low-level code. I use them all the time in inline assembly code - then again, there is no for loop in assembly.
 
@DomagojPandža Decaf?
 
8:41 AM
yo
 
9:04 AM
20
Q: Do we still have a case against the goto statement?

FredOverflow Possible Duplicate: Is it ever worthwhile using goto? In a recent article, Andrew Koenig writes: When asked why goto statements are harmful, most programmers will say something like "because they make programs hard to understand." Press harder, and you may well hear something like ...

 
9:15 AM
what about it?
 
@Fred: I agree (with what I telepathically think you mean), the alleged duplicate is about more "in general", while your question is about C++ in particular. That said, nearly all modern programming languages offer functional abstraction.
 
43
A: 'goto' usage

JUST MY correct OPINIONEverybody who is anti-goto cites, directly or indirectly, Edsger Dijkstra's GoTo Considered Harmful article to substantiate their position. Too bad Dijkstra's article has virtually nothing to do with the way goto statements are used these days and thus what the article says has little to no appl...

 
hm, i can "improve" the question (wanton damage), but i can't vote to reopen.
silly
 
> It's not language features that make unreadable, unmaintainable code. It's not syntax that does it. It's bad programmers that cause this. And bad programmers, as you can see in that above item, can make any language feature unreadable and unusable.
It's a controversial answer, but this part I find beautiful.
 
well
I usually avoid them - I can't think of when I've used them outside of inline assembly.
 
9:20 AM
And there's nothing wrong with not using a goto. Just promise you won't start and/or join a religious cult based on that ;-)
 
i think there are good reasons to avoid goto in C++
including:
* Makes bad practice for failure handling (goto common cleanup)
 
which is good practice in C
 
* Makes bad practice for expressing loops (play it again, Sam)
 
right
By the way, is it okay to use gotos inside a Singleton?
 
* Can possibly make control flow too "complicated" to factor out functions, and then it just gets longer and worse, ad spaghetti
huh?
 
9:22 AM
Inheritance can make control flow way more complicated than gotos. Sometimes it gets so bad you have to consult a debugger to figure out what's going on.
 
yes, but it's not control flow that you care about
you care about algorithmic control flow in local code
not about which function override is called
at the point of calling a function, it is already black-box abstracted
 
@StackedCrooked It's an experiment of mine, can't really classify it. :Đ
 
so no need to know the details of the flow inside that
 
hmmm
 
Personally, I have never seen a complicated function riddled with gotos in the real world. I have heard many horror stories about such functions, but all I have actually seen so far are contrived examples.
 
9:26 AM
> "But," they will chant, "you can make code very difficult to read with goto in C." Oh yeah? You can make code very difficult to read without goto as well
 
@FredOverflow Probably because nearly everybody here was born, let alone started programming, after it was already mostly killed off
 
Personally, I cannot imagine an incomprehensible C++ function that was incomprehensible because of the way goto was used, and that wasn't a contrived example.
In BASIC, sure, you can jump from anywhere to anywhere, but it's just not possible in C++.
 
@FredOverflow Because C++ will accurately prevent gotoing around non-POD types
 
right
 
but it also makes goto fairly useless
there's basically no situations at all in which you might want to use it and the language will permit it
 
9:28 AM
I think I used it on occasion for breaking out of nested loops.
 
not to mention that with the introduction of lambdas, things like multi-level loop breaking are already taken care of
 
I have written so much code, I am unable to quantize it - never have I had the need to use goto. No exceptions.
Don't get what's the fuss or the benefit from using it.
 
You use neither goto nor exceptions?
 
no exceptions?
what's wrong with you?
 
9:30 AM
I virtually never return error codes - well with the exception of a few times I was writing in C.
 
Wait, what?
 
exceptions are a necessity in C++
hell, they're just a necessity
exceptions are so much better than return codes that a blind man could see it
 
Exceptions in the sense of the English language.
xd
 
oh
lol
whoopsie
I never realized that ambiguity before
I'm gonna steal it and make a joke out of it
and take all the credit
 
lol
 
9:33 AM
by the way, I had idea
solving SHA-2 == solving 489-SAT (n == 256)?
 
I have no idea what you're talking about.
security issues?
 
what I'm talking about is solving SHA-2 maybe NP-Complete
 
Third coffee today. Still feeling like I derefenced a dangling pointer.
 
@DeadMG Somehow I have never been enthusiastic about all the P/NP fuzz.
 
9:37 AM
@FredOverflow It's kinda important.
 
@DeadMG So is relativity theory, but it's just not for me.
 
@FredOverflow it has renewed interest because an efficiently traveling salesman reduces CO2 emissions
 
@CheersandhthAlf P = NP has way more ramifications than that.
 
How exactly is O(2^n) related to P/NP?
 
9:39 AM
there's a vast number of NP-complete and NP-hard problems where having efficient solutions would be very beneficial
@FredOverflow It's not, strictly. However, basically, O(2^n/2) give or take is the best known complexity for any NP-complete problem.
 
if each salesman can do the job with just O(n^2) car rides (say), then that reduces CO2 emissions, surely?
 
Aren't the car rides always n if he travels n cities? :)
 
It actually is useful, knowing to analyze a given problem properly and try to reduce the number of necessary operations. Sure, you can have the same amount of fun by punching yourself in the face, but nonetheless - it can be useful and benificial.
 
The traveling salesman problem is about finding the shortest route between the n cities, and finding the shortest route is the hard part.
 
9:42 AM
but the shortest route uses least gasoline, yes?
 
That's the assumption, yes.
just found it, reading now
 
he's a moron
manual memory management -> epic fail
 
I never thought the C++ hello world was a good start actually. I mean, if you think about it, you have namespaces, operator overloading and objects all in one example.
 
hmm, his problem wasn't to do with that?
 
Buy the traveling salesman an Opel Ampera. No CO2 emissions if he can afford to stop every 60 km. If not, simply resort to the standard combustion engine (500 km range) which in turn drives the generator. Therefore, if emissions are related to distance traveled (say emission per 100 km), then for the first 60 km, you're traveling CO2 free and for the rest of it - reduced CO2 emissions due to the non-hybrid design.
And if can hold his breath for the travel time, even more win :Đ
Only downside is that the thing is quiet, can barely hear it. Someone not careful won't hear you and end up being a splat on the road. Or your windshield.
 
9:52 AM
Isn't the traveling salesman deprecated now that we have amazon and viagra spam?
 
lol
no, they just need it for their delivery trucks
 
This was a triumph...
I'm making a note here:
"Huge success".
 
@Jeremy Hello world is just one line in Python, isn't it? Maybe we should start teaching programmers with Python.
 
@FredOverflow I prefer to teach with the most flexible language
 
@FredOverflow Better yet, program a piece of paper with a pencil to say "Hello, world!"
 
9:55 AM
well, insofar as I actually teach anyone#
which would have to be C++
no other language can go from SSE intrinsics and pointer jiggling to functional and OO concepts and strong generics
if you teach someone Python, you automatically exclude being able to teach them SSE, or static typing, or something like that
 
My point is, hello world would be easier if it used the standard C library. Just one function and its arguments. Much easier to explain without getting in to things like namespaces, objects, and operator overloading
 
And when you teach someone C++ properly, they can adapt to any other language - even mock them for their lack of capability.
 
@Jeremy No, because then people would use the C Standard library.
 
but hello world doesn't try to teach the standard C or C++ library
 
it's great for printf("hello world") but the moment you go beyond that, it's a giant pile of suck
 
9:58 AM
nor does it try to teach namespaces or objects
 
and some poor smart student will look up printf and start experimenting with it's friend functions
@Jeremy People need to know those things.
 
Not to mention you're using the C std library.
 
@Jeremy Ok, so C# and Java must be hardest languages of all
 
To teach C++.
 
@DeadMG That would be LISP, right?
 
9:58 AM
Except namespaces and objects are basics of C++.
You can't just skip them.
 
@FredOverflow As far as I know, it offers neither deterministic destruction, nor SSE intrinsics, nor static typing
 
You need to approach every language by its own merits. No cheating, taking it slow, but taking it correctly.
 
Because printf is "easier" (it's not).
 
@DeadMG I don't think beginners should worry about SSE and pointers.
 
They need to know these things, but you don't expect someone doing hello world to grasp namespaces, objecrs and operator overloading all at once
 
9:59 AM
Also morning.
You don't have to go to I/O for hello world, either.
 
@FredOverflow Nor do I. But it helps not to have to learn another language when it is time.
 

« first day (589 days earlier)      last day (4344 days later) »