5 ms·
Boost.Lambda (https://www.boost.org/doc/libs/1_62_0/doc/html/lambda.html https://www.boost.org/doc/libs/1_62_0/doc/html/lambda.html) is probably what you want,
by nneonneo 3y ago
Boost.Lambda (https://www.boost.org/doc/libs/1_62_0/doc/html/lambda.html https://www.boost.org/doc/libs/1_62_0/doc/html/lambda.html) is probably what you want, and even predates the introduction of proper lambdas into C++!
Here’s a few simple examples cribbed from their documentation:
// Set all elements to 1
for_each(a.begin(), a.end(), _1 = 1);
// Print elements separated by spaces
for_each(b.begin(), b.end(), std::cout << _1 << ' ');
// Sort in reverse order
sort(c.begin(), c.end(), *_1 > *_2);