Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler
0005 //  Copyright Christopher Di Bella
0006 //
0007 //  Use, modification and distribution is subject to the
0008 //  Boost Software License, Version 1.0. (See accompanying
0009 //  file LICENSE_1_0.txt or copy at
0010 //  http://www.boost.org/LICENSE_1_0.txt)
0011 //
0012 // Project home: https://github.com/ericniebler/range-v3
0013 //
0014 #ifndef RANGES_V3_ACTION_ADJACENT_REMOVE_IF_HPP
0015 #define RANGES_V3_ACTION_ADJACENT_REMOVE_IF_HPP
0016 
0017 #include <utility>
0018 
0019 #include <range/v3/range_fwd.hpp>
0020 
0021 #include <range/v3/action/action.hpp>
0022 #include <range/v3/action/erase.hpp>
0023 #include <range/v3/algorithm/adjacent_remove_if.hpp>
0024 #include <range/v3/functional/bind_back.hpp>
0025 #include <range/v3/functional/identity.hpp>
0026 #include <range/v3/range/traits.hpp>
0027 #include <range/v3/utility/static_const.hpp>
0028 
0029 #include <range/v3/detail/prologue.hpp>
0030 
0031 namespace ranges
0032 {
0033     /// \addtogroup group-actions
0034     /// @{
0035     namespace actions
0036     {
0037         struct adjacent_remove_if_fn
0038         {
0039             template(typename Pred, typename Proj = identity)(
0040                 requires (!range<Pred>))
0041             constexpr auto operator()(Pred pred, Proj proj = {}) const
0042             {
0043                 return make_action_closure(
0044                     bind_back(adjacent_remove_if_fn{}, std::move(pred), std::move(proj)));
0045             }
0046 
0047             template(typename Rng, typename Pred, typename Proj = identity)(
0048                 requires forward_range<Rng> AND
0049                     erasable_range<Rng, iterator_t<Rng>, sentinel_t<Rng>> AND
0050                     indirect_relation<Pred, projected<iterator_t<Rng>, Proj>> AND
0051                     permutable<iterator_t<Rng>>)
0052             Rng operator()(Rng && rng, Pred pred, Proj proj = {}) const
0053             {
0054                 auto i = adjacent_remove_if(rng, std::move(pred), std::move(proj));
0055                 erase(rng, std::move(i), end(rng));
0056                 return static_cast<Rng &&>(rng);
0057             }
0058         };
0059 
0060         /// \relates actions::adjacent_remove_if_fn
0061         RANGES_INLINE_VARIABLE(adjacent_remove_if_fn, adjacent_remove_if)
0062     } // namespace actions
0063     /// @}
0064 } // namespace ranges
0065 
0066 #include <range/v3/detail/epilogue.hpp>
0067 
0068 #endif // RANGES_V3_ACTION_ADJACENT_REMOVE_IF_HPP