Re:Lambda-style anonymous functions for C++ in less than 500...
by fadmmatt on Tuesday April 13, 2010 @01:21PM
(#1262677)
Neat; but C++0x does this:
[](int x, int y) { return x + y; }
instead of this:
lambda<int> (x,y) --> x + y
Ironically, the template hack could be shorter in many cases.
Re:Lambda-style anonymous functions for C++ in less than 500...
by tbrownaw on Tuesday April 13, 2010 @02:15PM
(#1262858)
And those few extra characters give you an enormous amount of flexibility, such as not needing to define wrapper template specializations for all your types, not needing to have extra variables sitting around to define your argument placeholders, and being able to use more than just simple expressions.
Re:Lambda-style anonymous functions for C++ in less than 500...
by tman on Tuesday April 13, 2010 @12:28PM
(#1262484)
Unfortunate that this is one part of the C++0x g++ project that has yet to get serious. (At least the last time I checked out the g++ experimental code a few months ago.) C++0x lambdas are the one thing that I've been wanting to try out for years.
Instead, we got a lot of (now somewhat wasted) effort on concepts. I like concepts in principle, but too many C++ people saw concepts as a way to write provable code and unreadable library documentation instead of as a way to simplify compiler error messages.
Re:Lambda-style anonymous functions for C++ in less than 500...
by scott_s on Tuesday April 13, 2010 @12:41PM
(#1262532)
Prepare to be pleasantly surprised: http://gcc.gnu.org/projects/cxx0x.html
Also, real currying in C++0x: http://pastebin.com/KRraz7iU