Take std::sort
and std::ranges::sort
as examples, the iterator class in std::ranges::sort
is constrained with the concept std::random_access_iterator
:
template< std::random_access_iterator I, std::sentinel_for<I> S,
class Comp = ranges::less, class Proj = std::identity >
requires std::sortable<I, Comp, Proj>
constexpr I
sort( I first, S last, Comp comp = {}, Proj proj = {} );
But std::sort
is not:
template< class RandomIt >
void sort( RandomIt first, RandomIt last );
Why isn’t std::sort
(and all non-ranged algorithms) constrained?
A related question: What is the difference between std::fill_n and std::ranges::fill_n?