MySQL 9.6.0
Source Code Documentation
mysql::iterators Namespace Reference

Namespaces

namespace  detail
 

Classes

class  Default_sentinel
 Used like std::default_sentinel_t / std::default_sentinel. More...
 
class  Empty_sequence_iterator
 Iterator over an empty sequence. More...
 
class  Iterator_interface
 CRTP base class (mixin) that makes your class a standard-compliant iterator, given only a minimal set of functions to read, move and compare iterators. More...
 

Concepts

concept  Is_input_iterator_impl
 True if Type has the members required for Iterator_interface<Type> to satisfy std::input_iterator.
 
concept  Is_legacy_input_iterator_impl
 True if Type has the members required for Iterator_interface<Type> to meet the syntactic requirements for LegacyInputIterator.
 
concept  Is_legacy_forward_iterator_impl
 True if Type has the members and the value type for required for Iterator_interface<Type> to meet the syntactic requirements for LegacyForwardIterator.
 
concept  Is_legacy_bidirectional_iterator_impl
 true if Type has the members required for Iterator_interface<Type> to meet the syntactic requirements for LegacyBidirectionalIterator.
 
concept  Is_legacy_random_access_iterator_impl
 true if Type has the members required for Iterator_interface<Type> to meet the syntactic requirements for LegacyRandomAccessIterator.
 
concept  Is_legacy_contiguous_iterator_impl
 true if Type has the members required for Iterator_interface<Type> to meet the syntactic requirements for LegacyContiguousIterator.
 
concept  Is_declared_legacy_input_iterator
 True if the iterator is declared to meet LegacyInputIterator requirements.
 
concept  Is_declared_legacy_forward_iterator
 True if the iterator is declared to meet LegacyForwardIterator requirements.
 
concept  Is_declared_legacy_bidirectional_iterator
 True if the iterator is declared to meet LegacyBidirectionalIterator requirements.
 
concept  Is_declared_legacy_random_access_iterator
 True if the iterator is declared to meet LegacyRandomAccessIterator requirements.
 

Typedefs

template<class Iterator_t >
using Iterator_concept_tag = std::conditional_t< std::contiguous_iterator< Iterator_t >, std::contiguous_iterator_tag, std::conditional_t< std::random_access_iterator< Iterator_t >, std::random_access_iterator_tag, std::conditional_t< std::bidirectional_iterator< Iterator_t >, std::bidirectional_iterator_tag, std::conditional_t< std::forward_iterator< Iterator_t >, std::forward_iterator_tag, std::conditional_t< std::input_iterator< Iterator_t >, std::input_iterator_tag, void > > > > >
 

Functions

template<class Iterator_t >
requires std::derived_from<Iterator_t, Iterator_interface<Iterator_t>> && detail::Has_equality_member<Iterator_t>
bool operator== (const Iterator_t &a, const Iterator_t &b)
 Equality operator, which returns true if the two iterators are equal. More...
 
template<class Iterator_t >
requires std::derived_from<Iterator_t, Iterator_interface<Iterator_t>> && ( requires { Iterator_t().distance_from_sentinel(); } || requires { Iterator_t().is_sentinel(); })
bool operator== (const Iterator_t &it, const Default_sentinel &)
 Equality operator, which returns true if the iterator is equal to the sentinel. More...
 
template<class Iterator_t >
requires std::derived_from<Iterator_t, Iterator_interface<Iterator_t>> && detail::Has_member_advance<Iterator_t>
Iterator_t operator+ (std::ptrdiff_t delta, const Iterator_t &iterator)
 Addition operator with the left-hand-side of type ptrdiff_t and the right-hand-side of Iterator type, returning a new iterator that is ahead of the given iterator by the given number of steps. More...
 
template<class Iterator_t >
std::ptrdiff_t operator- (const Iterator_t &iterator, const Default_sentinel &)
 Subtraction operator with the left-hand-side of Iterator type and the right-hand-side of Sentinel type, returning the number of steps from the sentinel to the iterator (which is non-positive). More...
 
template<class Iterator_t >
std::ptrdiff_t operator- (const Default_sentinel &, const Iterator_t &iterator)
 Subtraction operator with the left-hand-side of Sentinel type and the right-hand-side of Iterator type, returning the number of steps from the iterator to the sentinel (which is non-negative). More...
 
template<class Iterator_t >
requires std::derived_from<Iterator_t, Iterator_interface<Iterator_t>> && detail::Has_member_distance_from<Iterator_t>
std::strong_ordering operator<=> (const Iterator_t &it1, const Iterator_t &it2)
 Three-way comparison operator which compares two Iterator objects and returns a std::strong_ordering object. More...
 
template<class Iterator_t >
requires std::derived_from<Iterator_t, Iterator_interface<Iterator_t>> && detail::Has_member_distance_from_sentinel<Iterator_t>
std::strong_ordering operator<=> (const Iterator_t &it1, const Default_sentinel &)
 Three-way comparison operator which compares an Iterator object and a Sentinel object and returns a std::strong_ordering object. More...
 
template<std::ranges::range Range_t>
auto null_iterator ()
 Returns an iterator object for a given range type, created without passing a range object, while guaranteeing that two such iterators for the same type compare as equal. More...
 

Variables

constexpr Default_sentinel default_sentinel
 

Typedef Documentation

◆ Iterator_concept_tag

template<class Iterator_t >
using mysql::iterators::Iterator_concept_tag = typedef std::conditional_t< std::contiguous_iterator<Iterator_t>, std::contiguous_iterator_tag, std::conditional_t< std::random_access_iterator<Iterator_t>, std::random_access_iterator_tag, std::conditional_t< std::bidirectional_iterator<Iterator_t>, std::bidirectional_iterator_tag, std::conditional_t< std::forward_iterator<Iterator_t>, std::forward_iterator_tag, std::conditional_t<std::input_iterator<Iterator_t>, std::input_iterator_tag, void> >> >>

Function Documentation

◆ null_iterator()

template<std::ranges::range Range_t>
auto mysql::iterators::null_iterator ( )

Returns an iterator object for a given range type, created without passing a range object, while guaranteeing that two such iterators for the same type compare as equal.

The use case is a view which does not have a range: then the view can return null iterators from its begin and end member functions, making it behave as a view over an empty range.

Note that default-constructed iterators do not generally work in this case, because comparison for default-constructed standard library iterators is undefined behavior.

This is implemented by returning the end iterator for a (singleton) default-constructed range object.

◆ operator+()

template<class Iterator_t >
requires std::derived_from<Iterator_t, Iterator_interface<Iterator_t>> && detail::Has_member_advance<Iterator_t>
Iterator_t mysql::iterators::operator+ ( std::ptrdiff_t  delta,
const Iterator_t &  iterator 
)

Addition operator with the left-hand-side of type ptrdiff_t and the right-hand-side of Iterator type, returning a new iterator that is ahead of the given iterator by the given number of steps.

This delegates work to advance.

◆ operator-() [1/2]

template<class Iterator_t >
std::ptrdiff_t mysql::iterators::operator- ( const Default_sentinel ,
const Iterator_t &  iterator 
)

Subtraction operator with the left-hand-side of Sentinel type and the right-hand-side of Iterator type, returning the number of steps from the iterator to the sentinel (which is non-negative).

This delegates work to distance_from_sentinel().

◆ operator-() [2/2]

template<class Iterator_t >
std::ptrdiff_t mysql::iterators::operator- ( const Iterator_t &  iterator,
const Default_sentinel  
)

Subtraction operator with the left-hand-side of Iterator type and the right-hand-side of Sentinel type, returning the number of steps from the sentinel to the iterator (which is non-positive).

This delegates work to distance_from_sentinel.

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

template<class Iterator_t >
requires std::derived_from<Iterator_t, Iterator_interface<Iterator_t>> && detail::Has_member_distance_from_sentinel<Iterator_t>
std::strong_ordering mysql::iterators::operator<=> ( const Iterator_t &  it1,
const Default_sentinel  
)

Three-way comparison operator which compares an Iterator object and a Sentinel object and returns a std::strong_ordering object.

This delegates work to distance_from_sentinel().

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

template<class Iterator_t >
requires std::derived_from<Iterator_t, Iterator_interface<Iterator_t>> && detail::Has_member_distance_from<Iterator_t>
std::strong_ordering mysql::iterators::operator<=> ( const Iterator_t &  it1,
const Iterator_t &  it2 
)

Three-way comparison operator which compares two Iterator objects and returns a std::strong_ordering object.

This delegates work to distance_from.

◆ operator==() [1/2]

template<class Iterator_t >
requires std::derived_from<Iterator_t, Iterator_interface<Iterator_t>> && detail::Has_equality_member<Iterator_t>
bool mysql::iterators::operator== ( const Iterator_t &  a,
const Iterator_t &  b 
)

Equality operator, which returns true if the two iterators are equal.

This delegates the work to the member function is_equal if there is one; otherwise to distance_from.

◆ operator==() [2/2]

template<class Iterator_t >
requires std::derived_from<Iterator_t, Iterator_interface<Iterator_t>> && ( requires { Iterator_t().distance_from_sentinel(); } || requires { Iterator_t().is_sentinel(); })
bool mysql::iterators::operator== ( const Iterator_t &  it,
const Default_sentinel  
)

Equality operator, which returns true if the iterator is equal to the sentinel.

This delegates the work to the member function is_equal if there is one; otherwise to distance_from.

Variable Documentation

◆ default_sentinel

constexpr Default_sentinel mysql::iterators::default_sentinel
inlineconstexpr