One of the very impressive features are lambda functions (IMHO):
for_each(a.begin(), a.end(), std::cout << _1 << ' ');
"std::cout << _1 << ' '" defines lambda function object taking one parameter.
Unfortunately, one cannot totally freely define those. Correct me, if I am wrong, but the following should not be possible:
for_each(a.begin(), a.end(), std::cout << "blupps: " << _1 << ' ');
The "<<" is evaluated from left to right. That means that std:cout << "blupps: " is evaluated before the special magic _1 can interfere and "blupps: " is printed immediately. (there is some special function to make this possible, I do not remember)
Functional conditional statements like "if_then" etc. are also provided for usage inside of lambda functions.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds