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 #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 
26 #include <range/v3/utility/static_const.hpp>
27 
28 #include <range/v3/detail/prologue.hpp>
29 
30 namespace ranges
31 {
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
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 
68  } // namespace actions
70 } // namespace ranges
71 
72 #include <range/v3/detail/epilogue.hpp>
73 
74 #endif
CPP_concept permutable
\concept permutable
Definition: concepts.hpp:840
CPP_concept indirect_relation
\concept indirect_relation
Definition: concepts.hpp:670
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
CPP_concept erasable_range
\concept erasable_range
Definition: erase.hpp:76
defer< bind_back, Fn, Ts... > bind_back
Definition: meta.hpp:994
Tiny meta-programming library.
Definition: remove.hpp:37
Definition: comparisons.hpp:28
Definition: identity.hpp:25