Horizon
Loading...
Searching...
No Matches
is_partitioned.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//===-------------------------- 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
27
35#include <range/v3/utility/static_const.hpp>
36
37#include <range/v3/detail/prologue.hpp>
38
39namespace ranges
40{
43 RANGES_FUNC_BEGIN(is_partitioned)
44
45
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
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 }
76} // namespace ranges
77
78#include <range/v3/detail/epilogue.hpp>
79
80#endif
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition meta.hpp:541
front< Pair > first
Retrieve the first element of the pair Pair.
Definition meta.hpp:2251
Tiny meta-programming library.