Horizon
remove.hpp
Go to the documentation of this file.
1 // 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 
24 #include <range/v3/range_fwd.hpp>
25 
29 #include <range/v3/view/view.hpp>
30 
31 #include <range/v3/detail/prologue.hpp>
32 
33 namespace 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
57  input_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
67  input_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 
103  } // namespace views
105 } // namespace ranges
106 
107 #include <range/v3/detail/epilogue.hpp>
108 
109 #endif // RANGES_V3_VIEW_REMOVE_HPP
CPP_concept indirectly_comparable
\concept indirectly_comparable
Definition: concepts.hpp:832
decltype(begin(declval(Rng &))) iterator_t
Definition: access.hpp:698
RANGES_INLINE_VARIABLE(detail::to_container_fn< detail::from_range< std::vector >>, to_vector) template< template< typename... > class ContT > auto to(RANGES_HIDDEN_DETAIL(detail
For initializing a container of the specified type with the elements of an Range.
Definition: conversion.hpp:399
defer< bind_back, Fn, Ts... > bind_back
Definition: meta.hpp:994
Tiny meta-programming library.
Definition: comparisons.hpp:28
Definition: remove.hpp:40
Definition: remove.hpp:78
Definition: remove.hpp:95