File indexing completed on 2025-01-18 10:09:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef RANGES_V3_ACTION_REMOVE_HPP
0014 #define RANGES_V3_ACTION_REMOVE_HPP
0015
0016 #include <meta/meta.hpp>
0017
0018 #include <range/v3/range_fwd.hpp>
0019
0020 #include <range/v3/action/action.hpp>
0021 #include <range/v3/action/erase.hpp>
0022 #include <range/v3/algorithm/remove.hpp>
0023 #include <range/v3/functional/bind_back.hpp>
0024 #include <range/v3/range/concepts.hpp>
0025 #include <range/v3/range/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 remove_fn
0037 {
0038 template(typename V, typename P)(
0039 requires (!range<V>))
0040 constexpr auto operator()(V && value, P proj) const
0041 {
0042 return make_action_closure(
0043 bind_back(remove_fn{}, static_cast<V &&>(value), std::move(proj)));
0044 }
0045
0046 template<typename V>
0047 constexpr auto operator()(V && value) const
0048 {
0049 return make_action_closure(
0050 bind_back(remove_fn{}, static_cast<V &&>(value), identity{}));
0051 }
0052
0053 template(typename Rng, typename V, typename P = identity)(
0054 requires forward_range<Rng> AND permutable<iterator_t<Rng>> AND
0055 erasable_range<Rng, iterator_t<Rng>, sentinel_t<Rng>> AND
0056 indirect_relation<equal_to, projected<iterator_t<Rng>, P>,
0057 V const *>)
0058 Rng operator()(Rng && rng, V const & value, P proj = {}) const
0059 {
0060 auto it = ranges::remove(rng, value, std::move(proj));
0061 ranges::erase(rng, it, ranges::end(rng));
0062 return static_cast<Rng &&>(rng);
0063 }
0064 };
0065
0066
0067 RANGES_INLINE_VARIABLE(remove_fn, remove)
0068 }
0069
0070 }
0071
0072 #include <range/v3/detail/epilogue.hpp>
0073
0074 #endif