Debian Codegraph @

3rd_party/range-v3/range/v3/algorithm/find_if_not.hpp

raw
1 /// \file
2 // Range v3 library
3 //
4 // Copyright Eric Niebler 2013-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_FIND_IF_NOT_HPP
14 #define RANGES_V3_ALGORITHM_FIND_IF_NOT_HPP
15
16 #include <utility>
17
18 #include <range/v3/range_fwd.hpp>
19
20 #include <range/v3/functional/identity.hpp>
21 #include <range/v3/functional/invoke.hpp>
22 #include <range/v3/iterator/concepts.hpp>
23 #include <range/v3/iterator/traits.hpp>
24 #include <range/v3/range/access.hpp>
25 #include <range/v3/range/concepts.hpp>
26 #include <range/v3/range/dangling.hpp>
27 #include <range/v3/range/traits.hpp>
28 #include <range/v3/utility/static_const.hpp>
29
30 #include <range/v3/detail/prologue.hpp>
31
32 namespace ranges
33 {
34 /// \addtogroup group-algorithms
35 /// @{
36 RANGES_FUNC_BEGIN(find_if_not)
37 /// \brief template function \c find_if_not
38 ///
39 /// range-based version of the \c find_if_not std algorithm
40 ///
41 /// \pre `Rng` is a model of the `range` concept
42 /// \pre `I` is a model of the `input_iterator` concept
43 /// \pre `S` is a model of the `sentinel_for<I>` concept
44 /// \pre `P` is a model of the `invocable<V>` concept, where `V` is the
45 /// value type of I.
46 /// \pre `F` models `predicate<X>`, where `X` is the result type
47 /// of `invocable<P, V>`
48 template(typename I, typename S, typename F, typename P = identity)(
49 requires input_iterator<I> AND sentinel_for<S, I> AND
50 indirect_unary_predicate<F, projected<I, P>>)
51 constexpr I RANGES_FUNC(find_if_not)(I first, S last, F pred, P proj = P{})
52 {
53 for(; first != last; ++first)
54 if(!invoke(pred, invoke(proj, *first)))
55 break;
56 return first;
57 }
58
59 /// \overload
60 template(typename Rng, typename F, typename P = identity)(
61 requires input_range<Rng> AND
62 indirect_unary_predicate<F, projected<iterator_t<Rng>, P>>)
63 constexpr borrowed_iterator_t<Rng> //
64 RANGES_FUNC(find_if_not)(Rng && rng, F pred, P proj = P{})
65 {
66 return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj));
67 }
68
69 RANGES_FUNC_END(find_if_not)
70
71 namespace cpp20
72 {
73 using ranges::find_if_not;
74 }
75 /// @}
76 } // namespace ranges
77
78 #include <range/v3/detail/epilogue.hpp>
79
80 #endif