Date: Sat, 22 May 2021 01:02:24 +0300
Hi, in his tweet
<https://twitter.com/ericniebler/status/1363891897773797379>, Eric Niebler
says that one can have a random-access proxy iterator in C++20. I've read
his series of articles
<https://ericniebler.com/2015/03/03/iterators-plus-plus-part-3/> and also
this paper
<https://ericniebler.github.io/std/wg21/D0022.html#permutable-proxy-iterators>
but there's one thing I can't understand. Let's take `std::ranges::sort()`
for example, it requires input range to be `std::sortable` which in turn
requires `std::indirectly_swappable` which is specified in terms of
`std::ranges::iter_swap()` which is a customization point for such proxy
iterators. The question is: is `std::ranges::sort()` itself required to use
`std::ranges::iter_swap()` internally? I can't find such a requirement and
libstdc++ doesn't use it(unlike range-v3). Without it, there's no sense in
satisfying `std::sortable` and the whole point of the random-access proxy
iterator is gone. It can't work if algorithms don't use these customization
points. It's pretty strange that algorithms are constrained by concepts
which they don't have to use in the actual implementation.
<https://twitter.com/ericniebler/status/1363891897773797379>, Eric Niebler
says that one can have a random-access proxy iterator in C++20. I've read
his series of articles
<https://ericniebler.com/2015/03/03/iterators-plus-plus-part-3/> and also
this paper
<https://ericniebler.github.io/std/wg21/D0022.html#permutable-proxy-iterators>
but there's one thing I can't understand. Let's take `std::ranges::sort()`
for example, it requires input range to be `std::sortable` which in turn
requires `std::indirectly_swappable` which is specified in terms of
`std::ranges::iter_swap()` which is a customization point for such proxy
iterators. The question is: is `std::ranges::sort()` itself required to use
`std::ranges::iter_swap()` internally? I can't find such a requirement and
libstdc++ doesn't use it(unlike range-v3). Without it, there's no sense in
satisfying `std::sortable` and the whole point of the random-access proxy
iterator is gone. It can't work if algorithms don't use these customization
points. It's pretty strange that algorithms are constrained by concepts
which they don't have to use in the actual implementation.
-- Regards, Oleksandr Koval.
Received on 2021-05-21 17:02:38