Boost logo

Boost :

From: Fletcher, John P (j.p.fletcher_at_[hidden])
Date: 2020-09-28 21:08:34


I have been playing around with lambda2 to see what I can do.

I have an example from where the task is to increment an array of integers:

std::vector<><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 - - polytechnique<>
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.

From: Boost <boost-bounces_at_[hidden]> on behalf of Peter Dimov via Boost <boost_at_[hidden]>
Sent: 08 September 2020 22:51
To: boost_at_[hidden] <boost_at_[hidden]>
Cc: Peter Dimov <pdimov_at_[hidden]>
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:

Boost list run by bdawes at, gregod at, cpdaniel at, john at