24#ifndef MYSQL_RANGES_FLAT_VIEW_H
25#define MYSQL_RANGES_FLAT_VIEW_H
52 [[nodiscard]]
static constexpr const auto &
unfold(
53 const std::ranges::range
auto &
source) {
60template <
class Source_t,
class Unfold_t>
62 { Unfold_t::unfold(
source) } -> std::ranges::range;
66template <
class Source_t,
class Unfold_t>
68 std::remove_cvref_t<decltype(Unfold_t::unfold(std::declval<Source_t>()))>;
72template <
class Source_t,
class Unfold_t>
79template <
class Source_tp,
class Unfold_tp>
105template <
class Unfold_t = Default_unfold, Can_unfold_with<Unfold_t> Source_t>
110 return Unfold_t::unfold(
source);
115template <
class Source_t,
class Unfold_t>
116 requires Can_unfold_with<Source_t, Unfold_t>
118 std::declval<Source_t>()))>;
138template <
class Outer_range_tp,
class Unfold_tp>
140 Flat_iterator<Outer_range_tp, Unfold_tp>> {
169 :
m_outer(outer_range, outer_iterator) {
178 [[nodiscard]]
decltype(
auto)
get()
const {
return *
m_inner; }
216template <
class Unfold_t,
class Range_t>
219 constexpr bool has_inner_range =
221 if constexpr (has_inner_range) {
234template <
class Source_tp,
class Unfold_tp>
236 public std::ranges::view_base {
250 return make_flat_iterator<Unfold_t>(
range,
range.begin());
252 [[nodiscard]]
auto end()
const {
CRTP base class (mixin) that makes your class a standard-compliant iterator, given only a minimal set...
Definition: iterator_interface.h:370
CRTP base class to provide members of a collection based on an implementation that provides begin/end...
Definition: collection_interface.h:90
Iterator adaptor that recursively flattens the sequence of a given iterator over a nested sequence.
Definition: flat_view.h:140
void next()
Definition: flat_view.h:180
void reset_inner()
Definition: flat_view.h:192
Outer_t m_outer
The outer range and current iterator to it.
Definition: flat_view.h:207
Flat_iterator(const Outer_range_t &outer_range)
Definition: flat_view.h:175
bool is_equal(const Flat_iterator &other) const
Definition: flat_view.h:185
Flat_view_type< Inner_source_t, Unfold_t > Inner_range_t
Definition: flat_view.h:160
Iterator_value_type< Outer_iterator_t > Inner_source_t
Definition: flat_view.h:159
mysql::ranges::Range_const_iterator_type< Outer_range_t > Outer_iterator_t
Definition: flat_view.h:158
void fix_position()
While not at a valid position, advance the positions.
Definition: flat_view.h:198
Inner_t m_inner
The range and iterator that m_outer.iterator() currently points to.
Definition: flat_view.h:210
Iterator_with_range< Inner_range_t > Inner_t
Definition: flat_view.h:163
Unfold_tp Unfold_t
Definition: flat_view.h:156
Outer_range_tp Outer_range_t
Definition: flat_view.h:155
decltype(auto) get() const
Definition: flat_view.h:178
Flat_iterator(const Outer_range_t &outer_range, const Outer_iterator_t &outer_iterator)
Definition: flat_view.h:167
Forward declaration.
Definition: flat_view.h:236
auto begin() const
Definition: flat_view.h:248
Unfold_tp Unfold_t
Definition: flat_view.h:238
auto end() const
Definition: flat_view.h:252
Flat_view(const Source_t &source)
Definition: flat_view.h:245
Source_tp Source_t
Definition: flat_view.h:237
Unfolded_type< Source_t, Unfold_t > Range_t
Definition: flat_view.h:240
Range_ref_t m_range
Definition: flat_view.h:258
bool is_end() const
Definition: iterator_with_range.h:103
const Raw_source_t & get() const
Return a copy of the stored object if it is owned; otherwise a reference to it.
Definition: view_sources.h:125
True if Source_t can be unfolded, and also the value type for the unfolded range can be unfolded,...
Definition: flat_view.h:73
True if Unfold_t<Source_t>unfold(Source_t) is defined and returns a range.
Definition: flat_view.h:61
Definition: buffer_interface.h:40
std::remove_cvref_t< decltype(std::declval< const Range_t >().begin())> Range_const_iterator_type
Gives the const_iterator type, deduced from the begin() const member.
Definition: meta.h:47
std::remove_cvref_t< decltype(make_flat_view< Unfold_t >(std::declval< Source_t >()))> Flat_view_type
Type of the flat view returned from make_flat_view<Unfold_t>(Source_T&).
Definition: flat_view.h:118
std::remove_cvref_t< decltype(Unfold_t::unfold(std::declval< Source_t >()))> Unfolded_type
Provides the type of the range returned from unfold<Unfold_t>(Source_t).
Definition: flat_view.h:68
std::remove_cvref_t< decltype(*std::declval< Iterator_t >())> Iterator_value_type
Gives the value type for any iterator type, deduced from operator *.
Definition: meta.h:63
auto make_flat_iterator(const Range_t &range, const Range_const_iterator_type< Range_t > &iterator)
Returns a flat iterator over the range starting at iterator.
Definition: flat_view.h:217
decltype(auto) make_flat_view(const Source_t &source)
Factory function to create a range view over a flattened sequence of elements from given source.
Definition: flat_view.h:106
const char * begin(const char *const c)
Definition: base64.h:44
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42
Default Unfold class.
Definition: flat_view.h:51
static constexpr const auto & unfold(const std::ranges::range auto &source)
Definition: flat_view.h:52
Definition: gen_lex_token.cc:149
const int end
Definition: gen_lex_token.cc:233