Horizon
Loading...
Searching...
No Matches
remove.hpp
Go to the documentation of this file.
1
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
14#ifndef RANGES_V3_VIEW_REMOVE_HPP
15#define RANGES_V3_VIEW_REMOVE_HPP
16
17#include <type_traits>
18#include <utility>
19
20#include <meta/meta.hpp>
21
22#include <concepts/concepts.hpp>
23
25
30
31#include <range/v3/detail/prologue.hpp>
32
33namespace ranges
34{
37 namespace views
38 {
40 {
41 private:
42 template<typename Value>
43 struct pred_
44 {
45 Value value_;
46 template(typename T)(
47 requires equality_comparable_with<T, Value const &>)
48 bool operator()(T && other) const
49 {
50 return static_cast<T &&>(other) == value_;
51 }
52 };
53
54 public:
55 template(typename Rng, typename Value)(
56 requires move_constructible<Value> AND viewable_range<Rng> AND
59 constexpr auto operator()(Rng && rng, Value value) const
60 {
61 return remove_if(static_cast<Rng &&>(rng),
62 pred_<Value>{std::move(value)});
63 }
64
65 template(typename Rng, typename Value, typename Proj)(
66 requires move_constructible<Value> AND viewable_range<Rng> AND
68 indirectly_comparable<iterator_t<Rng>, Value const *, equal_to, Proj>)
69 constexpr auto operator()(Rng && rng, Value value, Proj proj) const
70 {
71 return remove_if(static_cast<Rng &&>(rng),
72 pred_<Value>{std::move(value)},
73 std::move(proj));
74 }
75 };
76
78 {
79 template<typename Value>
80 constexpr auto operator()(Value value) const // TODO: underconstrained
81 {
82 return make_view_closure(bind_back(remove_base_fn{}, std::move(value)));
83 }
84 template(typename Value, typename Proj)(
85 requires (!range<Value>)) // TODO: underconstrained
86 constexpr auto operator()(Value && value, Proj proj) const
87 {
88 return make_view_closure(bind_back(
89 remove_base_fn{}, static_cast<Value &&>(value), std::move(proj)));
90 }
91 };
92
93 struct RANGES_EMPTY_BASES remove_fn
95 {
96 using remove_base_fn::operator();
97 using remove_bind_fn::operator();
98 };
99
102 RANGES_INLINE_VARIABLE(remove_fn, remove)
103 } // namespace views
105} // namespace ranges
106
107#include <range/v3/detail/epilogue.hpp>
108
109#endif // RANGES_V3_VIEW_REMOVE_HPP
The indirectly_comparable concept.
The input_range concept.
The range concept.
The viewable_range concept.
decltype(begin(declval(Rng &))) iterator_t
Definition access.hpp:698
Tiny meta-programming library.
Definition comparisons.hpp:28
Definition remove.hpp:40
Definition remove.hpp:78
Definition remove.hpp:95