Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:42

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2013-present
0005 //
0006 //  Use, modification and distribution is subject to the
0007 //  Boost Software License, Version 1.0. (See accompanying
0008 //  file LICENSE_1_0.txt or copy at
0009 //  http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // Project home: https://github.com/ericniebler/range-v3
0012 //
0013 
0014 #ifndef RANGES_V3_ACTION_SORT_HPP
0015 #define RANGES_V3_ACTION_SORT_HPP
0016 
0017 #include <range/v3/range_fwd.hpp>
0018 
0019 #include <range/v3/action/action.hpp>
0020 #include <range/v3/algorithm/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     /// \addtogroup group-actions
0033     /// @{
0034     namespace actions
0035     {
0036         struct sort_fn
0037         {
0038             template(typename C, typename P = identity)(
0039                 requires (!range<C>))
0040             constexpr auto operator()(C pred, P proj = {}) const
0041             {
0042                 return make_action_closure(
0043                     bind_back(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 = {}, P proj = {}) const
0049             {
0050                 ranges::sort(rng, std::move(pred), std::move(proj));
0051                 return static_cast<Rng &&>(rng);
0052             }
0053         };
0054 
0055         /// \relates actions::sort_fn
0056         /// \sa action_closure
0057         RANGES_INLINE_VARIABLE(action_closure<sort_fn>, sort)
0058     } // namespace actions
0059     /// @}
0060 } // namespace ranges
0061 
0062 #include <range/v3/detail/epilogue.hpp>
0063 
0064 #endif