Horizon
Loading...
Searching...
No Matches
remove_copy_if.hpp
Go to the documentation of this file.
1
2// Range v3 library
3//
4// Copyright Eric Niebler 2014-present
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_ALGORITHM_REMOVE_COPY_IF_HPP
14#define RANGES_V3_ALGORITHM_REMOVE_COPY_IF_HPP
15
16#include <meta/meta.hpp>
17
19
20#include <range/v3/algorithm/result_types.hpp>
29#include <range/v3/utility/static_const.hpp>
30
31#include <range/v3/detail/prologue.hpp>
32
33namespace ranges
34{
37 template<typename I, typename O>
38 using remove_copy_if_result = detail::in_out_result<I, O>;
39
40 RANGES_FUNC_BEGIN(remove_copy_if)
41
42
43 template(typename I, typename S, typename O, typename C, typename P = identity)(
44 requires input_iterator<I> AND sentinel_for<S, I> AND
45 weakly_incrementable<O> AND indirect_unary_predicate<C, projected<I, P>> AND
47 constexpr remove_copy_if_result<I, O> //
48 RANGES_FUNC(remove_copy_if)(I first, S last, O out, C pred, P proj = P{}) //
49 {
50 for(; first != last; ++first)
51 {
52 auto && x = *first;
53 if(!(invoke(pred, invoke(proj, x))))
54 {
55 *out = (decltype(x) &&)x;
56 ++out;
57 }
58 }
59 return {first, out};
60 }
61
63 template(typename Rng, typename O, typename C, typename P = identity)(
65 indirect_unary_predicate<C, projected<iterator_t<Rng>, P>> AND
67 constexpr remove_copy_if_result<borrowed_iterator_t<Rng>, O> //
68 RANGES_FUNC(remove_copy_if)(Rng && rng, O out, C pred, P proj = P{}) //
69 {
70 return (*this)(
71 begin(rng), end(rng), std::move(out), std::move(pred), std::move(proj));
72 }
73
74 RANGES_FUNC_END(remove_copy_if)
75
76 namespace cpp20
77 {
78 using ranges::remove_copy_if;
79 using ranges::remove_copy_if_result;
80 } // namespace cpp20
82} // namespace ranges
83
84#include <range/v3/detail/epilogue.hpp>
85
86#endif
The indirect_unary_predicate concept.
The indirectly_copyable concept.
The input_iterator concept.
The input_range concept.
The sentinel_for concept.
The weakly_incrementable concept.
decltype(begin(declval(Rng &))) iterator_t
Definition access.hpp:698
front< Pair > first
Retrieve the first element of the pair Pair.
Definition meta.hpp:2251
Tiny meta-programming library.
Definition identity.hpp:25