MySQL 9.6.0
Source Code Documentation
mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp > Class Template Reference

Iterator used by Disjoint_pairs_interface and Disjoint_pairs_view: this yields the disjoint, adjacent pairs of values from the source iterator. More...

#include <disjoint_pairs.h>

Inheritance diagram for mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >:
[legend]

Public Types

using Source_iterator_t = Source_iterator_tp
 
using Make_pair_t = Make_pair_tp
 
using Source_value_t = mysql::ranges::Iterator_value_type< Source_iterator_t >
 
using Value_t = decltype(Make_pair_t::make_pair(std::declval< Source_value_t >(), std::declval< Source_value_t >()))
 

Public Member Functions

 Disjoint_pairs_iterator () noexcept=default
 Default constructor, which leaves the object in a state that is not usable, except it can be assigned to. More...
 
 Disjoint_pairs_iterator (const Source_iterator_t &position) noexcept
 Construct a new iterator, where the first component points to the given position. More...
 
Value_t get () const
 
void next ()
 Move to the next position. More...
 
void prev ()
 Move to the previous position. More...
 
void advance (std::ptrdiff_t delta)
 Move the iterator the given number of steps. More...
 
std::ptrdiff_t distance_from (const Disjoint_pairs_iterator &other) const
 
bool is_equal (const Disjoint_pairs_iterator &other) const
 
- Public Member Functions inherited from mysql::iterators::Iterator_interface< Disjoint_pairs_iterator< Source_iterator_tp, detail::Make_pair > >
decltype(auto) operator* () const
 Dereference operator, which returns the current value. More...
 
auto operator-> () const
 Arrow operator, return a pointer (possibly a fancy pointer) to the current element. More...
 
Self_toperator++ ()
 Pre-increment operator, which advances the position one step and returns a reference to the iterator itself. More...
 
auto operator++ (int)
 Post-increment operator, which advances the position one step. More...
 
Self_toperator-- ()
 Pre-decrement iterator, which moves one step back and returns a reference to the iterator itself. More...
 
auto operator-- (int)
 Post-decrement operator, which moves one step back and returns a copy of the iterator before the decrement. More...
 
Self_toperator+= (std::ptrdiff_t delta)
 Addition assignment operator, which moves the iterator forward by the given number of steps, and returns a reference to the iterator itself. More...
 
Self_toperator-= (std::ptrdiff_t delta)
 Subtraction assignment operator, which moves the iterator backward by the given number of steps, and returns a reference to the iterator itself. More...
 
Self_t operator+ (std::ptrdiff_t delta) const
 Addition operator, which returns a new iterator that is the given number of steps ahead of the current iterator. More...
 
Self_t operator- (std::ptrdiff_t delta) const
 Subtraction-of-integer operator, which returns a new iterator that is the given number of steps behind of the current iterator. More...
 
std::ptrdiff_t operator- (const Self_t &other) const
 Subtraction-of-iterator operator, which returns the number of steps from other this. More...
 
decltype(auto) operator[] (std::ptrdiff_t delta) const
 Subscript operator, which returns a new iterator that is the given number of steps ahead of the current iterator. More...
 

Private Attributes

Source_iterator_t m_first
 Iterator to the first position. More...
 
std::optional< Source_iterator_tm_second
 Iterator to the second position. More...
 

Additional Inherited Members

- Protected Types inherited from mysql::iterators::Iterator_interface< Disjoint_pairs_iterator< Source_iterator_tp, detail::Make_pair > >
using Self_t = Disjoint_pairs_iterator< Source_iterator_tp, detail::Make_pair >
 

Detailed Description

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
class mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >

Iterator used by Disjoint_pairs_interface and Disjoint_pairs_view: this yields the disjoint, adjacent pairs of values from the source iterator.

This caches two iterator positions internally. It returns the pairs by value.

Template Parameters
Source_iterator_tpThe source iterator.
Make_pair_tpFunction object that creates a pair from two input values. By default, uses a function object that creates std::pair objects.

Member Typedef Documentation

◆ Make_pair_t

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
using mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::Make_pair_t = Make_pair_tp

◆ Source_iterator_t

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
using mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::Source_iterator_t = Source_iterator_tp

◆ Source_value_t

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
using mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::Source_value_t = mysql::ranges::Iterator_value_type<Source_iterator_t>

◆ Value_t

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
using mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::Value_t = decltype(Make_pair_t::make_pair( std::declval<Source_value_t>(), std::declval<Source_value_t>()))

Constructor & Destructor Documentation

◆ Disjoint_pairs_iterator() [1/2]

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::Disjoint_pairs_iterator ( )
defaultnoexcept

Default constructor, which leaves the object in a state that is not usable, except it can be assigned to.

Provided because std::input_iterator requires std::default_initializable.

◆ Disjoint_pairs_iterator() [2/2]

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::Disjoint_pairs_iterator ( const Source_iterator_t position)
inlineexplicitnoexcept

Construct a new iterator, where the first component points to the given position.

Member Function Documentation

◆ advance()

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
void mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::advance ( std::ptrdiff_t  delta)
inline

Move the iterator the given number of steps.

◆ distance_from()

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
std::ptrdiff_t mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::distance_from ( const Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp > &  other) const
inline
Returns
the number of steps from the other iterator to this iterator.

◆ get()

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
Value_t mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::get ( ) const
inline
Returns
the current value.

◆ is_equal()

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
bool mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::is_equal ( const Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp > &  other) const
inline
Returns
true if this iterator equals the other iterator.

◆ next()

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
void mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::next ( )
inline

Move to the next position.

◆ prev()

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
void mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::prev ( )
inline

Move to the previous position.

Member Data Documentation

◆ m_first

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
Source_iterator_t mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::m_first
private

Iterator to the first position.

◆ m_second

template<std::forward_iterator Source_iterator_tp, class Make_pair_tp = detail::Make_pair>
std::optional<Source_iterator_t> mysql::ranges::Disjoint_pairs_iterator< Source_iterator_tp, Make_pair_tp >::m_second
mutableprivate

Iterator to the second position.

This is mutable because it is only a cache and gets updated lazily.

(We cannot update this member when advancing the iterator, because that would make it advance past the past-the-end iterator, which is undefined behavior. Instead we unset it, and initialize it on the next dereference operation.)


The documentation for this class was generated from the following file: