I am coming from the C# world where I can write something like:
var newList = oldList.Select(x => x * 2).Where(x => x > 3).ToList();
This allows me to take a list, transform it in some way, and store the result in a new list.
I would like to do the same in C++ using range-v3. I understand how the transformations work, but does range-v3 provide similar "sink" methods for computing and collecting the results?
I am looking for something like toVector
, which would compute a resulting range into a freshly allocated std::vector
.
You may do:
Demo
Or, if you prefer
auto
on the left: