File indexing completed on 2025-01-18 10:09:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef RANGES_V3_ACTION_STABLE_SORT_HPP
0015 #define RANGES_V3_ACTION_STABLE_SORT_HPP
0016
0017 #include <range/v3/range_fwd.hpp>
0018
0019 #include <range/v3/action/action.hpp>
0020 #include <range/v3/algorithm/stable_sort.hpp>
0021 #include <range/v3/functional/bind_back.hpp>
0022 #include <range/v3/functional/comparisons.hpp>
0023 #include <range/v3/functional/identity.hpp>
0024 #include <range/v3/iterator/concepts.hpp>
0025 #include <range/v3/iterator/traits.hpp>
0026 #include <range/v3/utility/static_const.hpp>
0027
0028 #include <range/v3/detail/prologue.hpp>
0029
0030 namespace ranges
0031 {
0032
0033
0034 namespace actions
0035 {
0036 struct stable_sort_fn
0037 {
0038 template(typename C, typename P = identity)(
0039 requires (!range<C>))
0040 constexpr auto operator()(C pred, P proj = P{}) const
0041 {
0042 return make_action_closure(
0043 bind_back(stable_sort_fn{}, std::move(pred), std::move(proj)));
0044 }
0045
0046 template(typename Rng, typename C = less, typename P = identity)(
0047 requires forward_range<Rng> AND sortable<iterator_t<Rng>, C, P>)
0048 Rng operator()(Rng && rng, C pred = C{}, P proj = P{}) const
0049 {
0050 ranges::stable_sort(rng, std::move(pred), std::move(proj));
0051 return static_cast<Rng &&>(rng);
0052 }
0053 };
0054
0055
0056
0057 RANGES_INLINE_VARIABLE(action_closure<stable_sort_fn>, stable_sort)
0058 }
0059
0060 }
0061
0062 #include <range/v3/detail/epilogue.hpp>
0063
0064 #endif