21 #ifndef RANGES_V3_ALGORITHM_PARTITION_HPP
22 #define RANGES_V3_ALGORITHM_PARTITION_HPP
37 #include <range/v3/utility/static_const.hpp>
40 #include <range/v3/detail/prologue.hpp>
50 template<
typename I,
typename S,
typename C,
typename P>
51 constexpr I partition_impl(I
first, S last, C pred, P proj, std::forward_iterator_tag)
61 for(I p =
first; ++p != last;)
65 ranges::iter_swap(
first, p);
72 template<
typename I,
typename S,
typename C,
typename P>
73 constexpr I partition_impl(I
first, S end_, C pred, P proj, std::bidirectional_iterator_tag)
75 I last = ranges::next(
first, end_);
91 ranges::iter_swap(
first, last);
98 RANGES_FUNC_BEGIN(partition)
101 template(
typename I,
typename S,
typename C,
typename P = identity)(
102 requires permutable<I> AND sentinel_for<S, I> AND
104 constexpr I RANGES_FUNC(partition)(I
first, S last, C pred, P proj = P{})
106 return detail::partition_impl(std::move(
first),
110 iterator_tag_of<I>());
114 template(
typename Rng,
typename C,
typename P = identity)(
115 requires forward_range<Rng> AND
permutable<iterator_t<Rng>> AND
117 constexpr borrowed_iterator_t<Rng> RANGES_FUNC(partition)(Rng && rng, C pred, P proj = P{})
119 return detail::partition_impl(begin(rng),
123 iterator_tag_of<iterator_t<Rng>>());
126 RANGES_FUNC_END(partition)
130 using ranges::partition;
135 #include <range/v3/detail/epilogue.hpp>
CPP_concept permutable
\concept permutable
Definition: concepts.hpp:840
CPP_concept indirect_unary_predicate
\concept indirect_unary_predicate
Definition: concepts.hpp:632
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