Debian Codegraph @

3rd_party/range-v3/range/v3/action/remove.hpp

raw
1 /// \file
2 // Range v3 library
3 //
4 // Copyright Andrey Diduh 2019
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 #ifndef RANGES_V3_ACTION_REMOVE_HPP
14 #define RANGES_V3_ACTION_REMOVE_HPP
15
16 #include <meta/meta.hpp>
17
18 #include <range/v3/range_fwd.hpp>
19
20 #include <range/v3/action/action.hpp>
21 #include <range/v3/action/erase.hpp>
22 #include <range/v3/algorithm/remove.hpp>
23 #include <range/v3/functional/bind_back.hpp>
24 #include <range/v3/range/concepts.hpp>
25 #include <range/v3/range/traits.hpp>
26 #include <range/v3/utility/static_const.hpp>
27
28 #include <range/v3/detail/prologue.hpp>
29
30 namespace ranges
31 {
32 /// \addtogroup group-actions
33 /// @{
34 namespace actions
35 {
36 struct remove_fn
37 {
38 template(typename V, typename P)(
39 requires (!range<V>))
40 constexpr auto operator()(V && value, P proj) const
41 {
42 return make_action_closure(
43 bind_back(remove_fn{}, static_cast<V &&>(value), std::move(proj)));
44 }
45
46 template<typename V>
47 constexpr auto operator()(V && value) const
48 {
49 return make_action_closure(
50 bind_back(remove_fn{}, static_cast<V &&>(value), identity{}));
51 }
52
53 template(typename Rng, typename V, typename P = identity)(
54 requires forward_range<Rng> AND permutable<iterator_t<Rng>> AND
55 erasable_range<Rng, iterator_t<Rng>, sentinel_t<Rng>> AND
56 indirect_relation<equal_to, projected<iterator_t<Rng>, P>,
57 V const *>)
58 Rng operator()(Rng && rng, V const & value, P proj = {}) const
59 {
60 auto it = ranges::remove(rng, value, std::move(proj));
61 ranges::erase(rng, it, ranges::end(rng));
62 return static_cast<Rng &&>(rng);
63 }
64 };
65
66 /// \relates actions::remove_fn
67 RANGES_INLINE_VARIABLE(remove_fn, remove)
68 } // namespace actions
69 /// @}
70 } // namespace ranges
71
72 #include <range/v3/detail/epilogue.hpp>
73
74 #endif