Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you zip with the new ranges library?

See: http://eel.is/c++draft/#ranges

Given two C++2a ranges (as in objects that conform to the ranges concept of the ranges library) a and b, of equal length, is there a way to zip them together such that:

for (const auto& [a,b] : zip(a,b))

does what you expect? That is, it returns a range that has something destructurable binding pairs:

(a.begin(), b.begin())
(a.begin()+1, b.begin()+1)
(a.begin()+2, b.begin()+2)
...
(a.end()-1, b.end()-1)
like image 868
Andrew Tomazos Avatar asked Feb 15 '19 20:02

Andrew Tomazos


1 Answers

As you can see, there is no zip_view currently in C++20 (as of this writing).

It was being proposed in P1035R4 (along with a handful of other adapters), the previous version of which was favorable received in San Diego and seemed like it has a very reasonable chance of landing in C++20. There are open questions regarding proxy references, but I don't think that's specific to zip.


Those questions regarding proxy references ended up causing zip to get dropped from P1035 and it was not adopted for C++20. Instead, zip is being proposed for C++23 as part of P2321 (which additionally includes a description of the kinds of proxy reference changes I mentioned).

like image 128
Barry Avatar answered Oct 19 '22 19:10

Barry