|
|
Warp wrote:
> The C++0x (well, C++1x, really) standard will most probably introduce
> lambda functions and closures, which addresses all these problems, and
> more. You will be able to write your function directly as a parameter
> to for_each() (or whichever generic function you want to use) as a
> lamdba function, and this lambda function can (optionally) have access
> to all the variables in scope.
std::vector<int> someList;
int total = 0;
std::for_each(someList.begin(), someList.end(), [&total](int x) {
total += x
});
std::cout << total;
I read in a blog that Visual Studio already has *many* of those features
implemented (in a version not yet released even as alpha).
And gcc website has a list with C++0x implementation status :)
Post a reply to this message
|
|