14 #ifndef RANGES_V3_VIEW_GROUP_BY_HPP
15 #define RANGES_V3_VIEW_GROUP_BY_HPP
17 #include <type_traits>
33 #include <range/v3/utility/static_const.hpp>
39 #include <range/v3/detail/config.hpp>
40 #include <range/v3/detail/prologue.hpp>
50 template<
typename Rng,
typename Fun>
53 is_finite<Rng>::value ? finite : range_cardinality<Rng>::value>
59 detail::non_propagating_cache<iterator_t<Rng>> second_;
60 semiregular_box_t<Fun> fun_;
65 semiregular_box_ref_or_val_t<Fun, false> fun_;
66 bool operator()(range_reference_t<Rng> r)
const
68 return invoke(fun_, *first_, r);
79 sentinel_t<Rng> last_;
80 semiregular_box_ref_or_val_t<Fun, false> fun_;
88 constexpr
explicit mixin(cursor && cur)
91 constexpr
explicit mixin(cursor
const & cur)
97 return this->get().cur_;
102 template<
typename I = iterator_t<Rng>>
105 return {cur_, next_cur_};
110 return {cur_, next_cur_};
116 next_cur_ = cur_ != last_
117 ? find_if_not(ranges::next(cur_), last_, pred{cur_, fun_})
123 return cur_ == last_;
125 bool equal(cursor
const & that)
const
127 return cur_ == that.cur_;
132 , next_cur_(next_cur)
140 cursor begin_cursor()
142 auto b = ranges::begin(rng_);
143 auto e = ranges::end(rng_);
146 second_ = b != e ? find_if_not(ranges::next(b), e, pred{b, fun_}) : b;
148 return {fun_, b, *second_, e};
154 : rng_(std::move(rng))
155 , fun_(std::move(fun))
163 #if RANGES_CXX_DEDUCTION_GUIDES >= RANGES_CXX_DEDUCTION_GUIDES_17
164 template(
typename Rng,
typename Fun)(
165 requires copy_constructible<Fun>)
167 ->group_by_view<views::all_t<Rng>, Fun>;
174 template(
typename Rng,
typename Fun)(
175 requires viewable_range<Rng> AND forward_range<Rng> AND
178 "views::group_by is deprecated. Please use views::chunk_by instead. "
179 "Note that views::chunk_by evaluates the predicate between adjacent "
183 return {all(
static_cast<Rng &&
>(rng)), std::move(fun)};
189 using group_by_base_fn::operator();
191 template<
typename Fun>
193 "views::group_by is deprecated. Please use views::chunk_by instead. "
194 "Note that views::chunk_by evaluates the predicate between adjacent "
196 constexpr
auto operator()(Fun fun)
const
209 #include <range/v3/detail/epilogue.hpp>
210 #include <range/v3/detail/satisfy_boost_range.hpp>
CPP_concept indirect_relation
\concept indirect_relation
Definition: concepts.hpp:670
decltype(begin(declval(Rng &))) iterator_t
Definition: access.hpp:698
RANGES_INLINE_VARIABLE(detail::to_container_fn< detail::from_range< std::vector >>, to_vector) template< template< typename... > class ContT > auto to(RANGES_HIDDEN_DETAIL(detail
For initializing a container of the specified type with the elements of an Range.
Definition: conversion.hpp:399
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition: meta.hpp:541
defer< bind_back, Fn, Ts... > bind_back
Definition: meta.hpp:994
front< Pair > first
Retrieve the first element of the pair Pair.
Definition: meta.hpp:2251
Definition: basic_iterator.hpp:47
Definition: default_sentinel.hpp:26
Definition: group_by.hpp:54
Definition: subrange.hpp:196
A utility for constructing a view from a (derived) type that implements begin and end cursors.
Definition: facade.hpp:66
Definition: group_by.hpp:173
Definition: group_by.hpp:188