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 Andrey Diduh 2019
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 #ifndef RANGES_V3_ACTION_UNSTABLE_REMOVE_IF_HPP
0014 #define RANGES_V3_ACTION_UNSTABLE_REMOVE_IF_HPP
0015 
0016 #include <utility>
0017 
0018 #include <concepts/concepts.hpp>
0019 
0020 #include <range/v3/range_fwd.hpp>
0021 
0022 #include <range/v3/action/action.hpp>
0023 #include <range/v3/action/erase.hpp>
0024 #include <range/v3/algorithm/unstable_remove_if.hpp>
0025 #include <range/v3/functional/bind_back.hpp>
0026 #include <range/v3/functional/identity.hpp>
0027 #include <range/v3/iterator/concepts.hpp>
0028 #include <range/v3/range/access.hpp>
0029 #include <range/v3/range/concepts.hpp>
0030 
0031 #include <range/v3/detail/prologue.hpp>
0032 
0033 namespace ranges
0034 {
0035     /// \addtogroup group-actions
0036     /// @{
0037     namespace actions
0038     {
0039         struct unstable_remove_if_fn
0040         {
0041             template(typename C, typename P = identity)(
0042                 requires (!range<C>))
0043             constexpr auto operator()(C pred, P proj = P{}) const
0044             {
0045                 return make_action_closure(
0046                     bind_back(unstable_remove_if_fn{}, std::move(pred), std::move(proj)));
0047             }
0048 
0049             template(typename Rng, typename C, typename P = identity)(
0050                 requires bidirectional_range<Rng> AND common_range<Rng> AND
0051                     permutable<iterator_t<Rng>> AND
0052                     indirect_unary_predicate<C, projected<iterator_t<Rng>, P>> AND
0053                     erasable_range<Rng, iterator_t<Rng>, iterator_t<Rng>>)
0054             Rng operator()(Rng && rng, C pred, P proj = P{}) const
0055             {
0056                 auto it = ranges::unstable_remove_if(ranges::begin(rng),
0057                                                      ranges::end(rng),
0058                                                      std::move(pred),
0059                                                      std::move(proj));
0060                 ranges::erase(rng, it, ranges::end(rng));
0061                 return static_cast<Rng &&>(rng);
0062             }
0063         };
0064 
0065         /// \sa `actions::unstable_remove_if_fn`
0066         RANGES_INLINE_VARIABLE(unstable_remove_if_fn, unstable_remove_if)
0067     } // namespace actions
0068     /// @}
0069 } // namespace ranges
0070 
0071 #include <range/v3/detail/epilogue.hpp>
0072 
0073 #endif // RANGES_V3_ACTION_UNSTABLE_REMOVE_IF_HPP