Date: Fri, 5 Jun 2026 16:40:52 +0200
On 6/5/26 12:25, Mital Ashok wrote:
> See <https://wg21.link/LWG3281>. std::ranges::subrange used to have a
> constructor that would accept a std::pair but it was removed, so unlikely
> to be added back. Similar reasoning would apply to begin/end for std::pair.
I'm not sure I buy that reasoning. Two iterators in a std::pair are
*more* likely to represent a range than two bare iterators outside of a
std::pair, but the C++ standard library is full of cases where an
iterator range is represented by two bare iterators. Including a
constructor for std::ranges::subrange.
I can see where an implicit conversion to std::pair to
std::ranges::subrange might be a problem, but that can be fixed by
making the constructor explicit.
Still, that leaves the other possibilities.
std::range::subrange_from_pair_of_iterators_representing_a_range, as
horrible as the name is, would still be an improvement over the current
situation. Or even a function
std::ranges::equal_subrange_from_associative which does nothing but call
equal_subrange on an associative container and return the result as a
std::ranges::subrange.
> See <https://wg21.link/LWG3281>. std::ranges::subrange used to have a
> constructor that would accept a std::pair but it was removed, so unlikely
> to be added back. Similar reasoning would apply to begin/end for std::pair.
I'm not sure I buy that reasoning. Two iterators in a std::pair are
*more* likely to represent a range than two bare iterators outside of a
std::pair, but the C++ standard library is full of cases where an
iterator range is represented by two bare iterators. Including a
constructor for std::ranges::subrange.
I can see where an implicit conversion to std::pair to
std::ranges::subrange might be a problem, but that can be fixed by
making the constructor explicit.
Still, that leaves the other possibilities.
std::range::subrange_from_pair_of_iterators_representing_a_range, as
horrible as the name is, would still be an improvement over the current
situation. Or even a function
std::ranges::equal_subrange_from_associative which does nothing but call
equal_subrange on an associative container and return the result as a
std::ranges::subrange.
-- Rainer Deyke - rainerd_at_[hidden]
Received on 2026-06-05 14:41:03
