Debian Codegraph @

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

raw
1 /// \file
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 //===-------------------------- algorithm ---------------------------------===//
14 //
15 // The LLVM Compiler Infrastructure
16 //
17 // This file is dual licensed under the MIT and the University of Illinois Open
18 // Source Licenses. See LICENSE.TXT for details.
19 //
20 //===----------------------------------------------------------------------===//
21 #ifndef RANGES_V3_ALGORITHM_IS_PARTITIONED_HPP
22 #define RANGES_V3_ALGORITHM_IS_PARTITIONED_HPP
23
24 #include <meta/meta.hpp>
25
26 #include <range/v3/range_fwd.hpp>
27
28 #include <range/v3/functional/identity.hpp>
29 #include <range/v3/functional/invoke.hpp>
30 #include <range/v3/iterator/concepts.hpp>
31 #include <range/v3/iterator/traits.hpp>
32 #include <range/v3/range/access.hpp>
33 #include <range/v3/range/concepts.hpp>
34 #include <range/v3/range/traits.hpp>
35 #include <range/v3/utility/static_const.hpp>
36
37 #include <range/v3/detail/prologue.hpp>
38
39 namespace ranges
40 {
41 /// \addtogroup group-algorithms
42 /// @{
43 RANGES_FUNC_BEGIN(is_partitioned)
44
45 /// \brief function template \c is_partitioned
46 template(typename I, typename S, typename C, typename P = identity)(
47 requires input_iterator<I> AND sentinel_for<S, I> AND
48 indirect_unary_predicate<C, projected<I, P>>)
49 constexpr bool RANGES_FUNC(is_partitioned)(I first, S last, C pred, P proj = P{}) //
50 {
51 for(; first != last; ++first)
52 if(!invoke(pred, invoke(proj, *first)))
53 break;
54 for(; first != last; ++first)
55 if(invoke(pred, invoke(proj, *first)))
56 return false;
57 return true;
58 }
59
60 /// \overload
61 template(typename Rng, typename C, typename P = identity)(
62 requires input_range<Rng> AND
63 indirect_unary_predicate<C, projected<iterator_t<Rng>, P>>)
64 constexpr bool RANGES_FUNC(is_partitioned)(Rng && rng, C pred, P proj = P{}) //
65 {
66 return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj));
67 }
68
69 RANGES_FUNC_END(is_partitioned)
70
71 namespace cpp20
72 {
73 using ranges::is_partitioned;
74 }
75 /// @}
76 } // namespace ranges
77
78 #include <range/v3/detail/epilogue.hpp>
79
80 #endif