Subject: Are random-access proxy iterators really supported by the standard library?
From: Oleksandr Koval (oleksandr.koval.dev_at_[hidden])
Date: 2021-05-21 17:02:24
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
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.
STD-DISCUSSION list run by firstname.lastname@example.org
Older Archives on Google Groups