Horizon
sort.hpp
Go to the documentation of this file.
1 // Range v3 library
3 //
4 // Copyright Eric Niebler 2013-present
5 //
6 // Use, modification and distribution is subject to the
7 // Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 //
11 // Project home: https://github.com/ericniebler/range-v3
12 //
13 
14 #ifndef RANGES_V3_ACTION_SORT_HPP
15 #define RANGES_V3_ACTION_SORT_HPP
16 
17 #include <range/v3/range_fwd.hpp>
18 
26 #include <range/v3/utility/static_const.hpp>
27 
28 #include <range/v3/detail/prologue.hpp>
29 
30 namespace ranges
31 {
34  namespace actions
35  {
36  struct sort_fn
37  {
38  template(typename C, typename P = identity)(
39  requires (!range<C>))
40  constexpr auto operator()(C pred, P proj = {}) const
41  {
42  return make_action_closure(
43  bind_back(sort_fn{}, std::move(pred), std::move(proj)));
44  }
45 
46  template(typename Rng, typename C = less, typename P = identity)(
47  requires forward_range<Rng> AND sortable<iterator_t<Rng>, C, P>)
48  Rng operator()(Rng && rng, C pred = {}, P proj = {}) const
49  {
50  ranges::sort(rng, std::move(pred), std::move(proj));
51  return static_cast<Rng &&>(rng);
52  }
53  };
54 
58  } // namespace actions
60 } // namespace ranges
61 
62 #include <range/v3/detail/epilogue.hpp>
63 
64 #endif
CPP_concept sortable
\concept sortable
Definition: concepts.hpp:865
decltype(begin(declval(Rng &))) iterator_t
Definition: access.hpp:698
RANGES_INLINE_VARIABLE(detail::to_container_fn< detail::from_range< std::vector >>, to_vector) template< template< typename... > class ContT > auto to(RANGES_HIDDEN_DETAIL(detail
For initializing a container of the specified type with the elements of an Range.
Definition: conversion.hpp:399
defer< bind_back, Fn, Ts... > bind_back
Definition: meta.hpp:994
bool_<(T::type::value< U::type::value)> less
A Boolean integral constant wrapper around true if T::type::value is less than U::type::value; false,...
Definition: meta.hpp:255
Definition: action.hpp:141
Definition: sort.hpp:37
Definition: identity.hpp:25