4 ms·
Though it doesn’t work with the standard algorithms. For example you can’t do stuff like: std::transform(first, last, lambda<int> (x) --> 2*x);
by sorbits 16y ago
Though it doesn’t work with the standard algorithms.
For example you can’t do stuff like:
std::transform(first, last, lambda<int> (x) --> 2*x);
- Jach 16y agoWhat are you talking about? You're missing an arg in your transform() call. int nums[] = {1, 2, 3}; printf("nums: %i %i %i\n", nums[0], nums[1], nums[2]); std::transform(nums, nums+3, nums, (lambda<int> (x) --> 2*x)); printf("new nums: %i %i %i\n", nums[0], nums[1], nums[2]); Edit: And of course, there's the implemented map he gives in the example: int* incs = (lambda<int> (x) --> x + 1).map(3,nums); The class needs a little bit of work obviously (like more operators overloaded), but it's pretty nice.