MySQL 9.6.0
Source Code Documentation
mysql::ranges Namespace Reference

Namespaces

namespace  detail
 

Classes

class  Buffer_interface
 CRTP base class that provides a rich API for classes that behave like byte buffers. More...
 
class  Collection_interface
 CRTP base class to provide members of a collection based on an implementation that provides begin/end iterators. More...
 
struct  Default_unfold
 Default Unfold class. More...
 
class  Disjoint_pairs_interface
 CRTP base used to define classes that yield disjoint, adjacent pairs of elements from an even-length source sequence. More...
 
class  Disjoint_pairs_iterator
 Iterator used by Disjoint_pairs_interface and Disjoint_pairs_view: this yields the disjoint, adjacent pairs of values from the source iterator. More...
 
class  Disjoint_pairs_view
 View over an even-length sequence, yielding the disjoint, adjacent pairs of elements. More...
 
class  Flat_iterator
 Iterator adaptor that recursively flattens the sequence of a given iterator over a nested sequence. More...
 
class  Flat_view
 Forward declaration. More...
 
class  Iterator_with_range
 Iterator that holds a reference to its source range. More...
 
class  Optional_view_source
 std::optional-like wrapper around an object that is the source for a view: this may hold an object or not; and the wrapped object is owned by this object if the wrapped object's type satisfies std::ranges::view, and not owned otherwise. More...
 
class  Transform_interface
 CRTP base class / mixin used to define ranges that provide Transform_iterators. More...
 
class  Transform_iterator
 Iterator adaptor that applies a transformation on each value before returning it. More...
 
class  Transform_view
 View whose iterators provide transformed values. More...
 
class  View_source
 Wrapper around an object that is the source for a view: the wrapped object is owned by this object if the wrapped object's type satisfies std::ranges::view, and not owned otherwise. More...
 

Concepts

concept  Can_unfold_with
 True if Unfold_t<Source_t>unfold(Source_t) is defined and returns a range.
 
concept  Can_unfold_twice_with
 True if Source_t can be unfolded, and also the value type for the unfolded range can be unfolded, using the given Unfold_t function.
 
concept  Is_iterator_for_range
 True if Iterator is either the iterator or the const iterator for Range_t.
 
concept  Is_collection
 True if Test has the properties of a "collection", i.e., a range with member functions to query size and emptiness.
 
concept  Is_collection_over
 True if Test models Is_collection, with Value_t as its value type.
 

Typedefs

template<class Source_t , class Unfold_t >
using Unfolded_type = std::remove_cvref_t< decltype(Unfold_t::unfold(std::declval< Source_t >()))>
 Provides the type of the range returned from unfold<Unfold_t>(Source_t). More...
 
template<class Source_t , class Unfold_t >
using Flat_view_type = std::remove_cvref_t< decltype(make_flat_view< Unfold_t >(std::declval< Source_t >()))>
 Type of the flat view returned from make_flat_view<Unfold_t>(Source_T&). More...
 
template<class Range_t >
using Range_iterator_type = std::remove_cvref_t< decltype(std::declval< Range_t >().begin())>
 Gives the iterator type, deduced from the begin() member. More...
 
template<class Range_t >
using Range_const_iterator_type = std::remove_cvref_t< decltype(std::declval< const Range_t >().begin())>
 Gives the const_iterator type, deduced from the begin() const member. More...
 
template<class Range_t >
using Range_sentinel_type = std::remove_cvref_t< decltype(std::declval< Range_t >().end())>
 Gives the iterator type, deduced from the end() member. More...
 
template<class Iterator_t >
using Iterator_value_type = std::remove_cvref_t< decltype(*std::declval< Iterator_t >())>
 Gives the value type for any iterator type, deduced from operator *. More...
 
template<class Range_t >
using Range_value_type = Iterator_value_type< Range_iterator_type< Range_t > >
 Gives the value type for any collection, deduced from *begin(). More...
 
template<class Map_t >
using Map_key_type = std::remove_cvref_t< decltype(std::declval< Map_t >().begin() ->first)>
 Gives the key type for any collection, deduced from begin()->first. More...
 
template<class Map_t >
using Map_mapped_type = std::remove_cvref_t< decltype(std::declval< Map_t >().begin() ->second)>
 Gives the mapped type for any collection, deduced from begin()->first. More...
 
template<std::size_t index_tp, std::input_iterator Source_iterator_tp>
using Projection_iterator = Transform_iterator< detail::Projection_transform< index_tp >, Source_iterator_tp >
 Projection iterator adaptor: given an iterator over tuple-like objects, this is an iterator over the Nth component. More...
 
template<std::size_t index_tp, std::ranges::range Source_tp>
using Projection_view = Transform_view< detail::Projection_transform< index_tp >, Source_tp >
 Projection view: given a range over tuple-like objects, this is a range over the N'th component of those tuples. More...
 
template<class Value_iterator_t >
using Key_iterator = Projection_iterator< 0, Value_iterator_t >
 Iterator adaptor that extracts the first component from tuple-like value types. More...
 
template<class Source_t >
using Key_view = Projection_view< 0, Source_t >
 View over the keys of a range of pairs. More...
 
template<class Value_iterator_t >
using Mapped_iterator = Projection_iterator< 1, Value_iterator_t >
 Iterator adaptor that extracts the second component from tuple-like value types. More...
 
template<class Source_t >
using Mapped_view = Projection_view< 1, Source_t >
 View over the mapped values in a range of pairs. More...
 
template<class Source_t , bool owns_source_t = std::ranges::view<Source_t>>
using Raw_view_source = std::conditional_t< owns_source_t, Source_t, const Source_t & >
 Type alias to represent the source of a view: resolves to Type if std::ranges::view<Type>, or to Type & otherwise. More...
 

Enumerations

enum class  Equality_algorithm { lexicographic , fast , none }
 
enum class  Enable_hash { no , yes }
 

Functions

template<std::derived_from< detail::Buffer_base > Buffer_t>
requires (Buffer_t::equality_algorithm == Equality_algorithm::fast)
auto operator<=> (const Buffer_t &left, const Buffer_t &right)
 Enable fast comparison operators for Buffer_interface subclasses. More...
 
template<std::derived_from< detail::Buffer_base > Buffer_t>
requires (Buffer_t::equality_algorithm == Equality_algorithm::lexicographic)
auto operator<=> (const Buffer_t &left, const Buffer_t &right)
 Enable lexicographic comparison operators for Buffer_interface subclasses. More...
 
template<std::derived_from< detail::Buffer_base > Buffer_t>
requires Buffer_t
::equality_enabled bool operator== (const Buffer_t &left, const Buffer_t &right)
 Enable operator== for Buffer_interface subclasses. More...
 
template<std::derived_from< detail::Buffer_base > Buffer_t>
requires Buffer_t
::equality_enabled bool operator!= (const Buffer_t &left, const Buffer_t &right)
 Enable operator!= for Buffer_interface subclasses. More...
 
template<class Pair_t = detail::Make_pair, class Iterator_t >
auto make_disjoint_pairs_iterator (const Iterator_t &position)
 Factory function to create a Disjoint_pairs_iterator. More...
 
template<class Make_pair_t = detail::Make_pair, class Source_t >
auto make_disjoint_pairs_view (const Source_t &source)
 Factory to construct a Disjoint_pairs_view from a given range. More...
 
template<class Unfold_t = Default_unfold, Can_unfold_with< Unfold_t > Source_t>
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. More...
 
template<class Unfold_t , class Range_t >
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. More...
 
template<std::size_t index_t, std::input_iterator Tuple_iterator_t>
auto make_projection_iterator (const Tuple_iterator_t &iterator)
 Factory function to create a Projection_iterator. More...
 
template<std::size_t index_t, std::ranges::range Source_t>
auto make_projection_view (const Source_t &source)
 Factory function to create a Projection_view. More...
 
auto make_key_iterator (const auto &iterator)
 Factory function to create a new iterator from a given iterator over pairs. More...
 
auto make_key_view (const auto &source)
 Factory function to create a new view over the keys in a range of pairs. More...
 
auto make_mapped_iterator (const auto &iterator)
 Factory function to create a new iterator from a given iterator over pairs. More...
 
auto make_mapped_view (const auto &source)
 Factory function to create a new view over the mapped values in a range of pairs. More...
 
template<class Transform_t , std::input_iterator Source_iterator_t>
auto make_transform_iterator (const Source_iterator_t &iterator)
 Factory function to create a Transform_iterator. More...
 
template<class Transform_t , std::ranges::range Source_t>
auto make_transform_view (const Source_t &source)
 Factory function to create a Transform_view. More...
 
template<class Source_t >
auto make_view_source (const Source_t &source)
 Factory function to create a View_source wrapping the given object. More...
 
template<class Source_t >
auto make_optional_view_source (const Source_t &source)
 Factory function to create an Optional_view_source wrapping the given object. More...
 
template<class Source_t >
auto make_optional_view_source (const Source_t *source)
 Factory function to create an Optional_view_source wrapping the pointed-to object. More...
 

Typedef Documentation

◆ Flat_view_type

template<class Source_t , class Unfold_t >
using mysql::ranges::Flat_view_type = typedef std::remove_cvref_t<decltype(make_flat_view<Unfold_t>( std::declval<Source_t>()))>

Type of the flat view returned from make_flat_view<Unfold_t>(Source_T&).

◆ Iterator_value_type

template<class Iterator_t >
using mysql::ranges::Iterator_value_type = typedef std::remove_cvref_t<decltype(*std::declval<Iterator_t>())>

Gives the value type for any iterator type, deduced from operator *.

◆ Key_iterator

template<class Value_iterator_t >
using mysql::ranges::Key_iterator = typedef Projection_iterator<0, Value_iterator_t>

Iterator adaptor that extracts the first component from tuple-like value types.

For example, Key_iterator<std::map::iterator> is an iterator over the keys in the map.

Template Parameters
Value_iterator_tSource iterator that yields value pairs.

◆ Key_view

template<class Source_t >
using mysql::ranges::Key_view = typedef Projection_view<0, Source_t>

View over the keys of a range of pairs.

Template Parameters
Source_tSource range.

◆ Map_key_type

template<class Map_t >
using mysql::ranges::Map_key_type = typedef std::remove_cvref_t<decltype(std::declval<Map_t>().begin()->first)>

Gives the key type for any collection, deduced from begin()->first.

For standard types such as std::map, the member type std::map::key_type can be used instead. This deduced type is usable in other cases, for example, when a map is "emulated" using std::vector<std::pair<K, V>>, or for user-defined types that do no have a key_type member.

◆ Map_mapped_type

template<class Map_t >
using mysql::ranges::Map_mapped_type = typedef std::remove_cvref_t<decltype(std::declval<Map_t>().begin()->second)>

Gives the mapped type for any collection, deduced from begin()->first.

For standard types such as std::map, the member type std::map::mapped_type can be used instead. This deduced type is usable in other cases, for example, when a map is "emulated" using std::vector<std::pair<K, V>>, or for user-defined types that do no have a key_type member.

◆ Mapped_iterator

template<class Value_iterator_t >
using mysql::ranges::Mapped_iterator = typedef Projection_iterator<1, Value_iterator_t>

Iterator adaptor that extracts the second component from tuple-like value types.

For example, Mapped_iterator<std::map::iterator> is an iterator over the mapped values in the map.

Template Parameters
Value_iterator_tSource iterator that yields value pairs.

◆ Mapped_view

template<class Source_t >
using mysql::ranges::Mapped_view = typedef Projection_view<1, Source_t>

View over the mapped values in a range of pairs.

Template Parameters
Source_tSource range.

◆ Projection_iterator

template<std::size_t index_tp, std::input_iterator Source_iterator_tp>
using mysql::ranges::Projection_iterator = typedef Transform_iterator<detail::Projection_transform<index_tp>, Source_iterator_tp>

Projection iterator adaptor: given an iterator over tuple-like objects, this is an iterator over the Nth component.

Template Parameters
index_tpThe index of the element to project on.
Source_iterator_tpThe source iterator, which should yield tuple-like objects.

◆ Projection_view

template<std::size_t index_tp, std::ranges::range Source_tp>
using mysql::ranges::Projection_view = typedef Transform_view<detail::Projection_transform<index_tp>, Source_tp>

Projection view: given a range over tuple-like objects, this is a range over the N'th component of those tuples.

Template Parameters
index_tpThe component index.
Source_tpThe source type, which should be a range over tuple-like objects.

◆ Range_const_iterator_type

template<class Range_t >
using mysql::ranges::Range_const_iterator_type = typedef std::remove_cvref_t<decltype(std::declval<const Range_t>().begin())>

Gives the const_iterator type, deduced from the begin() const member.

◆ Range_iterator_type

template<class Range_t >
using mysql::ranges::Range_iterator_type = typedef std::remove_cvref_t<decltype(std::declval<Range_t>().begin())>

Gives the iterator type, deduced from the begin() member.

◆ Range_sentinel_type

template<class Range_t >
using mysql::ranges::Range_sentinel_type = typedef std::remove_cvref_t<decltype(std::declval<Range_t>().end())>

Gives the iterator type, deduced from the end() member.

◆ Range_value_type

template<class Range_t >
using mysql::ranges::Range_value_type = typedef Iterator_value_type<Range_iterator_type<Range_t> >

Gives the value type for any collection, deduced from *begin().

◆ Raw_view_source

template<class Source_t , bool owns_source_t = std::ranges::view<Source_t>>
using mysql::ranges::Raw_view_source = typedef std::conditional_t<owns_source_t, Source_t, const Source_t &>

Type alias to represent the source of a view: resolves to Type if std::ranges::view<Type>, or to Type & otherwise.

This is meant to be used by member variables of the view class, or the view's iterator class, that need to reference the source.

This intends to prevent dangling references by enforcing the following rule:

"Views and their iterators shall represent sources that are views by-value, and sources that are containers by-reference."

For full justification, see readme.md.

Since references are not default-constructible, a view or view iterator that has a member of this type becomes non-default-constructible when the source is not a view. If you need default-constructibility, use View_source instead. The benefit of this class is that it does not require indirection to access the T object.

Note that types need to be declared explicitly as views, using either std::ranges::view_base or std::ranges::enable_range.

Template Parameters
Source_tThe source type.
owns_source_tDetermines if the object owns its source. By default, this is deduced from std::ranges::view<Source_t>.

◆ Unfolded_type

template<class Source_t , class Unfold_t >
using mysql::ranges::Unfolded_type = typedef std::remove_cvref_t<decltype(Unfold_t::unfold(std::declval<Source_t>()))>

Provides the type of the range returned from unfold<Unfold_t>(Source_t).

Enumeration Type Documentation

◆ Enable_hash

enum class mysql::ranges::Enable_hash
strong
Enumerator
no 
yes 

◆ Equality_algorithm

Enumerator
lexicographic 
fast 
none 

Function Documentation

◆ make_disjoint_pairs_iterator()

template<class Pair_t = detail::Make_pair, class Iterator_t >
auto mysql::ranges::make_disjoint_pairs_iterator ( const Iterator_t &  position)

Factory function to create a Disjoint_pairs_iterator.

◆ make_disjoint_pairs_view()

template<class Make_pair_t = detail::Make_pair, class Source_t >
auto mysql::ranges::make_disjoint_pairs_view ( const Source_t &  source)

Factory to construct a Disjoint_pairs_view from a given range.

Template Parameters
Make_pair_tClass containing a static member function make_pair that defines how to construct a pair from two adjacent elements. By default, uses detail::Make_pair, for which make_pair constructs and returns a std::pair object.
Source_tRange that this is a view over. It must have the member functions begin, end, empty, and size. The distance between begin and end must be even.
Returns
New Disjoint_pairs_view object.

◆ make_flat_iterator()

template<class Unfold_t , class Range_t >
auto mysql::ranges::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.

This is the appropriate Flat_iterator wrapper if Can_unfold_with is true for Iterator_t's value type; otherwise it is iterator itself.

◆ make_flat_view()

template<class Unfold_t = Default_unfold, Can_unfold_with< Unfold_t > Source_t>
decltype(auto) mysql::ranges::make_flat_view ( const Source_t &  source)

Factory function to create a range view over a flattened sequence of elements from given source.

For example, if source is of type std::vector<std::map<A, std::list<B>>>, make_flat_view(source) is a range view over B objects.

In case any map or list is empty, it is only skipped over; the resulting range contains only valid elements and no "gaps".

Template Parameters
Unfold_tUnfold class. This is used to obtain ranges from the source, and from its sub-objects. For example, we expect make_flat_view(std::map<A, std::map<B, C>>&) to provide iterators over C. While unfolding the outer map, the implementation needs a range over std::map<B, C> objects, and while unfolding each such inner std::map<B, C> object, the implementation needs a range over C objects. But std::map does not give that; it only gives ranges over std::pair<A, std::map<B, C>> and std::pair<B, C>. In such cases, the user needs to provide a custom Unfold class through this parameter, which should have a member function unfold(std::map<X, Y>) returning a range over Y objects.
Source_tType of source.
Parameters
sourceSource object.

◆ make_key_iterator()

auto mysql::ranges::make_key_iterator ( const auto &  iterator)

Factory function to create a new iterator from a given iterator over pairs.

Template Parameters
Value_iterator_tSource iterator that yields value pairs.

◆ make_key_view()

auto mysql::ranges::make_key_view ( const auto &  source)

Factory function to create a new view over the keys in a range of pairs.

Template Parameters
Source_tSource range.

◆ make_mapped_iterator()

auto mysql::ranges::make_mapped_iterator ( const auto &  iterator)

Factory function to create a new iterator from a given iterator over pairs.

Template Parameters
Value_iterator_tSource iterator that yields value pairs.

◆ make_mapped_view()

auto mysql::ranges::make_mapped_view ( const auto &  source)

Factory function to create a new view over the mapped values in a range of pairs.

Template Parameters
Source_tSource range.

◆ make_optional_view_source() [1/2]

template<class Source_t >
auto mysql::ranges::make_optional_view_source ( const Source_t &  source)

Factory function to create an Optional_view_source wrapping the given object.

◆ make_optional_view_source() [2/2]

template<class Source_t >
auto mysql::ranges::make_optional_view_source ( const Source_t *  source)

Factory function to create an Optional_view_source wrapping the pointed-to object.

◆ make_projection_iterator()

template<std::size_t index_t, std::input_iterator Tuple_iterator_t>
auto mysql::ranges::make_projection_iterator ( const Tuple_iterator_t &  iterator)

Factory function to create a Projection_iterator.

Template Parameters
index_tThe component index.
Tuple_iterator_tThe source iterator type.

◆ make_projection_view()

template<std::size_t index_t, std::ranges::range Source_t>
auto mysql::ranges::make_projection_view ( const Source_t &  source)

Factory function to create a Projection_view.

Template Parameters
index_tThe component index.
Source_tThe source type.

◆ make_transform_iterator()

template<class Transform_t , std::input_iterator Source_iterator_t>
auto mysql::ranges::make_transform_iterator ( const Source_iterator_t &  iterator)

Factory function to create a Transform_iterator.

Template Parameters
Transform_tThe transform.
Source_iterator_tThe source iterator type.

◆ make_transform_view()

template<class Transform_t , std::ranges::range Source_t>
auto mysql::ranges::make_transform_view ( const Source_t &  source)

Factory function to create a Transform_view.

Template Parameters
Transform_tThe transform.
Source_tThe source type.

◆ make_view_source()

template<class Source_t >
auto mysql::ranges::make_view_source ( const Source_t &  source)

Factory function to create a View_source wrapping the given object.

◆ operator!=()

template<std::derived_from< detail::Buffer_base > Buffer_t>
requires Buffer_t
::equality_enabled bool mysql::ranges::operator!= ( const Buffer_t &  left,
const Buffer_t &  right 
)
inline

Enable operator!= for Buffer_interface subclasses.

◆ operator<=>() [1/2]

template<std::derived_from< detail::Buffer_base > Buffer_t>
requires (Buffer_t::equality_algorithm == Equality_algorithm::fast)
auto mysql::ranges::operator<=> ( const Buffer_t &  left,
const Buffer_t &  right 
)
inline

Enable fast comparison operators for Buffer_interface subclasses.

◆ operator<=>() [2/2]

template<std::derived_from< detail::Buffer_base > Buffer_t>
requires (Buffer_t::equality_algorithm == Equality_algorithm::lexicographic)
auto mysql::ranges::operator<=> ( const Buffer_t &  left,
const Buffer_t &  right 
)
inline

Enable lexicographic comparison operators for Buffer_interface subclasses.

◆ operator==()

template<std::derived_from< detail::Buffer_base > Buffer_t>
requires Buffer_t
::equality_enabled bool mysql::ranges::operator== ( const Buffer_t &  left,
const Buffer_t &  right 
)
inline

Enable operator== for Buffer_interface subclasses.