Horizon
Loading...
Searching...
No Matches
partition_point_n.hpp
Go to the documentation of this file.
1
2// Range v3 library
3//
4// Copyright Eric Niebler 2014-present
5// Copyright Casey Carter 2016
6//
7// Use, modification and distribution is subject to the
8// Boost Software License, Version 1.0. (See accompanying
9// file LICENSE_1_0.txt or copy at
10// http://www.boost.org/LICENSE_1_0.txt)
11//
12// Project home: https://github.com/ericniebler/range-v3
13//
14#ifndef RANGES_V3_ALGORITHM_AUX_PARTITION_POINT_N_HPP
15#define RANGES_V3_ALGORITHM_AUX_PARTITION_POINT_N_HPP
16
18
22#include <range/v3/utility/static_const.hpp>
23
24#include <range/v3/detail/prologue.hpp>
25
26namespace ranges
27{
28 namespace aux
29 {
31 {
32 template(typename I, typename C, typename P = identity)(
33 requires forward_iterator<I> AND
34 indirect_unary_predicate<C, projected<I, P>>)
35 constexpr I operator()(I first,
36 iter_difference_t<I> d,
37 C pred,
38 P proj = P{}) const //
39 {
40 if(0 < d)
41 {
42 do
43 {
44 auto half = d / 2;
45 auto middle = next(uncounted(first), half);
46 if(invoke(pred, invoke(proj, *middle)))
47 {
48 first = recounted(first, std::move(++middle), half + 1);
49 d -= half + 1;
50 }
51 else
52 d = half;
53 } while(0 != d);
54 }
55 return first;
56 }
57 };
58
59 RANGES_INLINE_VARIABLE(partition_point_n_fn, partition_point_n)
60 } // namespace aux
61} // namespace ranges
62
63#include <range/v3/detail/epilogue.hpp>
64
65#endif
The forward_iterator concept.
The indirect_unary_predicate concept.
Definition partition_point_n.hpp:31
Definition identity.hpp:25