Debian Codegraph @

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

raw
1 /// \file
2 // Range v3 library
3 //
4 // Copyright Johel Guerrero 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_ALGORITHM_CONTAINS_HPP
14 #define RANGES_V3_ALGORITHM_CONTAINS_HPP
15
16 #include <utility>
17
18 #include <concepts/concepts.hpp>
19
20 #include <range/v3/algorithm/find.hpp>
21 #include <range/v3/detail/config.hpp>
22 #include <range/v3/functional/comparisons.hpp>
23 #include <range/v3/functional/identity.hpp>
24 #include <range/v3/iterator/concepts.hpp>
25 #include <range/v3/range/access.hpp>
26 #include <range/v3/range/concepts.hpp>
27
28 #include <range/v3/detail/prologue.hpp>
29
30 namespace ranges
31 {
32 /// \addtogroup group-algorithms
33 /// @{
34 RANGES_FUNC_BEGIN(contains)
35
36 /// \brief function template \c contains
37 template(typename I, typename S, typename T, typename P = identity)(
38 requires input_iterator<I> AND sentinel_for<S, I> AND
39 indirect_relation<equal_to, projected<I, P>, const T *>)
40 constexpr bool RANGES_FUNC(contains)(I first, S last, const T & val, P proj = {})
41 {
42 return find(std::move(first), last, val, std::move(proj)) != last;
43 }
44
45 /// \overload
46 template(typename Rng, typename T, typename P = identity)(
47 requires input_range<Rng> AND
48 indirect_relation<equal_to, projected<iterator_t<Rng>, P>, const T *>)
49 constexpr bool RANGES_FUNC(contains)(Rng && rng, const T & val, P proj = {})
50 {
51 return (*this)(begin(rng), end(rng), val, std::move(proj));
52 }
53
54 RANGES_FUNC_END(contains)
55 /// @}
56 } // namespace ranges
57
58 #include <range/v3/detail/epilogue.hpp>
59
60 #endif // RANGES_V3_ALGORITHM_CONTAINS_HPP