There is a zip_with
function provided by Eric Niebler.
But, now that C++20 have support for ranges I would like to build something similar.
The problem with filter
and transform
is that they iterate a range?
How would I go about doing this? I have been stuck with this for a while and would hate to use Expression Templates for the same.
Let's say for example I have two vectors M1{1,2,3} and M2{4,5,6}.
I would like to use the ranges library to overload a operator to return a view which contains matrix addition of these two - M1+M2 := {5,7,9}
.
With ranges-v3, I can perform auto sum = zip_with(std::plus,M1,M2);
The above expression is evaluated lazily. How can I re-create this expression with C++20 Ranges?
zip_with
?zip_with
works fine with C++20 ranges, what's wrong with it?