5 ms·
If you are interested in this subject, you might find the following pertinent: http://www.boost.org/doc/libs/1_42_0/doc/html/lambda.html http://www.boost.org/d
by slug 16y ago
If you are interested in this subject, you might find the following pertinent:
http://www.boost.org/doc/libs/1_42_0/doc/html/lambda.html http://www.boost.org/doc/libs/1_42_0/doc/html/lambda.html
and as someone posted here before:
http://gcc.gnu.org/projects/cxx0x.html http://gcc.gnu.org/projects/cxx0x.html
There's also an interview with a "brief" summary from Scott Meyers at http://www.se-radio.net/podcast/2010-04/episode-159-c0x-scott-meyers http://www.se-radio.net/podcast/2010-04/episode-159-c0x-scot... that mentions lambda functions.
- DCoder 16y agoAnother good intro to lambdas and more: http://blogs.msdn.com/vcblog/archive/2008/10/28/lambdas-auto-and-static-assert-c-0x-features-in-vc10-part-1.aspx http://blogs.msdn.com/vcblog/archive/2008/10/28/lambdas-auto... . It's for Microsoft's VC++ (including the free Express edition I'm using right now), not GCC, but the syntax is obviously the same in both cases.
- jimbokun 16y agoWow. Things that look like expressions, but are most definitely not, through the magic of operator overloading. So you can translate some expressions straightforwardly, but other expressions not, with the cases for what works and doesn't requiring careful thought. So this works: for_each(vp.begin(), vp.end(), cout << *_1 << '\n'); This doesn't: for_each(vp.begin(), vp.end(), cout << '\n' << *_1); But this does: for_each(vp.begin(), vp.end(), cout << constant('\n') << *_1); Considering how complex it is to figure out what works and what doesn't in that lambda slot, I'm not sure it's worth the effort. Of course I'm not a C++ programmer, and this is yet another reason why that might not be such a bad thing. (Note: this is regarding Boost lambda, if that wasn't clear.)
- scott_s 16y agoConsidering how complex it is to figure out what works and what doesn't in that lambda slot, I'm not sure it's worth the effort. I am a C++ programmer, and that's exactly the conclusion I came to regarding Boost's lambda. I use Boost's bind library all the time, though. But! C++0x has real lambdas, so we won't have to resort to this trickery much longer.