I'm writing a proxy iterator using Boost.STLInterfaces. It has inline
friend constexpr void iter_swap(iter lhs, iter rhs) noexcept
.
ranges::sort
requires, among others, std::indirectly_swappable
, which requires ranges::iter_swap
for the iterator. But with gcc-11.2.0 the call stack looks something like
1 my::swap item.hpp 91
2 std::iter_swap<my::iter, my::iter> stl_algobase.h 182
3 std::__move_median_to_first<...> stl_algo.h 92
4 std::__unguarded_partition_pivot<...> stl_algo.h 1904
5 std::__introsort_loop<...> stl_algo.h 1938
6 std::__sort<...> stl_algo.h 1954
7 std::sort<...> stl_algo.h 4875
8 std::ranges::__sort_fn::operator()<...> ranges_algo.h 2029
9 std::ranges::__sort_fn::operator()<...> ranges_algo.h 2040
10 operator() sort.cpp 68
11 main sort.cpp 82
i.e. ranges::sort calls std::sort, which does not use the customization, but calls std::iter_swap
explicitly. It still works because of the hidden friend swap for the reference type, though.
What is needed to make sure ranges::sort uses the customization?