From the documentation of ranges-v3:
view::all
Return a range containing all the elements in the source. Useful for converting containers to ranges.
What makes me confused are:
view::all
used?std::vector
, std::list
, etc.) not
ranges conceptually?For example:
auto coll = std::vector{ 1, 2, 2, 3 };
view::all(coll) | view::unique; // version 1
coll | view::unique; // version 2
Is there any difference between version 1
and version 2
?
Egad, that part of the documentation hasn't been updated since range-v3 switched terminology. Yes, a container is a Range (it has begin()
and end()
that return an iterator/sentinel pair). It is not a View (a Range with O(1) copy/move). So, the documentation for view::all
should read:
view::all
Return a View containing all the elements in the source. Useful for converting containers to Views.
To answer your second question, no there is no difference between version 1 and version 2 in your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With