
Hi I have been playing around with lambda2 to see what I can do. I have an example from http://www.enseignement.polytechnique.fr/informatique/INF478/docs/Cpp/en/cpp... where the task is to increment an array of integers: std::vector<http://www.enseignement.polytechnique.fr/informatique/INF478/docs/Cpp/en/cpp/container/vector.html><int> nums{3, 4, 2, 9, 15, 267}; std::for_each(nums.begin(), nums.end(), [](int &n){ n++; }); The nearest I can get with lambda2 is this: std::for_each( nums.begin(),nums.end(), (_1 + 1) ); This compiles although I have found no way to store back the result. John Fletcher std::for_each - cppreference.com - polytechnique<http://www.enseignement.polytechnique.fr/informatique/INF478/docs/Cpp/en/cpp/algorithm/for_each.html> Applies the given function object f to the result of dereferencing every iterator in the range [first, last), in order.. If InputIt is a mutable iterator, f may modify the elements of the range through the dereferenced iterator. If f returns a result, the result is ignored. www.enseignement.polytechnique.fr ________________________________ From: Boost <boost-bounces@lists.boost.org> on behalf of Peter Dimov via Boost <boost@lists.boost.org> Sent: 08 September 2020 22:51 To: boost@lists.boost.org <boost@lists.boost.org> Cc: Peter Dimov <pdimov@gmail.com> Subject: Re: [boost] Review Manager needed for Boost.Lambda2 Andrey Semashev wrote:
I also forgot operator[].
Must be a member. Unary *, however, probably needs to be added. *_1 < *_2 is a common case. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost