coveo::linq
Implementation of .NET-like LINQ operators in C++
Public Types | Public Member Functions | Friends | List of all members
coveo::enumerable< T >::iterator Class Reference

Iterator for elements in the sequence. More...

Public Types

using iterator_category = std::forward_iterator_tag
 Iterator category. More...
 
using value_type = typename enumerable< T >::value_type
 Type of elements returned by iterator. More...
 
using raw_value_type = typename enumerable< T >::raw_value_type
 Raw type of elements returned by iterator. More...
 
using difference_type = std::ptrdiff_t
 Difference type. More...
 
using pointer = typename enumerable< T >::pointer
 Pointer to elements returned by iterator. More...
 
using reference = typename enumerable< T >::reference
 Reference to elements returned by iterator. More...
 

Public Member Functions

 iterator ()=default
 Default constructor. More...
 
 iterator (const enumerable< T > &parent, bool is_end)
 Constructor from enumerable. More...
 
 iterator (const iterator &obj)=default
 Copy constructor. More...
 
 iterator (iterator &&obj)
 Move constructor. More...
 
iteratoroperator= (const iterator &obj)=default
 Assignment operator. More...
 
iteratoroperator= (iterator &&obj)
 Move assignment operator. More...
 
reference operator * () const
 Element access. More...
 
pointer operator-> () const
 Element pointer access. More...
 
iteratoroperator++ ()
 Moves to next element (pre-increment). More...
 
iterator operator++ (int)
 Moves to next element (post-increment). More...
 

Friends

bool operator== (const iterator &left, const iterator &right)
 Compares iterator for equality. More...
 
bool operator!= (const iterator &left, const iterator &right)
 Compares iterator for inequality. More...
 

Detailed Description

template<typename T>
class coveo::enumerable< T >::iterator

Iterator for elements in a coveo::enumerable's sequence. Uses the enumerable's next delegate to fetch references to the elements during iteration.

Elements are always late-initialized, e.g. they are not fetched from the next delegate until they are accessed.

See also
coveo::enumerable::begin()
coveo::enumerable::end()

Member Typedef Documentation

◆ iterator_category

template<typename T>
using coveo::enumerable< T >::iterator::iterator_category = std::forward_iterator_tag

Standard iterator typedef for iterator category. Because enumerable is a forward-only sequence, this corresponds to std::forward_iterator_tag to identify a ForwardIterator.

◆ value_type

template<typename T>
using coveo::enumerable< T >::iterator::value_type = typename enumerable<T>::value_type

Type of the elements returned by this iterator.

See also
coveo::enumerable::value_type

◆ raw_value_type

template<typename T>
using coveo::enumerable< T >::iterator::raw_value_type = typename enumerable<T>::raw_value_type

Type of the elements returned by this iterator, but "raw", e.g. without const or volatile.

See also
coveo::enumerable::raw_value_type

◆ difference_type

template<typename T>
using coveo::enumerable< T >::iterator::difference_type = std::ptrdiff_t

Standard iterator typedef for difference between iterators. Corresponds to std::ptfdiff_t.

◆ pointer

template<typename T>
using coveo::enumerable< T >::iterator::pointer = typename enumerable<T>::pointer

Pointer to the type of elements returned by this iterator.

See also
coveo::enumerable::pointer

◆ reference

template<typename T>
using coveo::enumerable< T >::iterator::reference = typename enumerable<T>::reference

Reference to the type of elements returned by this iterator. This is the type of reference returned by operator*().

See also
coveo::enumerable::reference.

Constructor & Destructor Documentation

◆ iterator() [1/4]

template<typename T>
coveo::enumerable< T >::iterator::iterator ( )
default

Default constructor. Creates an invalid iterator that cannot be dereferenced.

◆ iterator() [2/4]

template<typename T>
coveo::enumerable< T >::iterator::iterator ( const enumerable< T > &  parent,
bool  is_end 
)
inline

Constructor that is used by coveo::enumerable to create its iterators.

Parameters
parentParent enumerable to iterate.
is_endWhether this iterator should point to the beginning of the sequence (false) or to the end of the sequence (true).

◆ iterator() [3/4]

template<typename T>
coveo::enumerable< T >::iterator::iterator ( const iterator obj)
default

Copy constructor. Creates a copy of another iterator that will point to the same point in the enumeration.

Parameters
objIterator to copy.

◆ iterator() [4/4]

template<typename T>
coveo::enumerable< T >::iterator::iterator ( iterator &&  obj)
inline

Move constructor. Creates an iterator by moving the internals from another iterator. After this method returns, obj is invalid and cannot be used.

Parameters
objIterator to move.

Member Function Documentation

◆ operator=() [1/2]

template<typename T>
iterator& coveo::enumerable< T >::iterator::operator= ( const iterator obj)
default

Assignment operator. Copies another iterator, now pointing to the same point in the enumeration.

Parameters
objIterator to copy.
Returns
Reference to this iterator.

◆ operator=() [2/2]

template<typename T>
iterator& coveo::enumerable< T >::iterator::operator= ( iterator &&  obj)
inline

Move assignment operator. Moves the internals of another iterator to this one. After this method returns, obj is invalid and cannot be used.

Parameters
objIterator to move.
Returns
Reference to this iterator.

◆ operator *()

template<typename T>
reference coveo::enumerable< T >::iterator::operator * ( ) const
inline

Returns a reference to the current element in the enumeration, fetching it from the next delegate on the first call.

Returns
Reference to current element.

◆ operator->()

template<typename T>
pointer coveo::enumerable< T >::iterator::operator-> ( ) const
inline

Returns a pointer to the current element in the enumeration, fetching it from the next delegate on the first call. Can be used to call methods or access members of the element.

Returns
Pointer to current element.

◆ operator++() [1/2]

template<typename T>
iterator& coveo::enumerable< T >::iterator::operator++ ( )
inline

Moves forward to the next element in the enumeration. Cannot be used if this iterator points to the end of the enumeration.

Returns
Reference to this iterator AFTER the move.

◆ operator++() [2/2]

template<typename T>
iterator coveo::enumerable< T >::iterator::operator++ ( int  )
inline

Moves forward to the next element in the enumeration. Cannot be used if this iterator points to the end of the enumeration.

Returns
Iterator BEFORE the move.

Friends And Related Function Documentation

◆ operator==

template<typename T>
bool operator== ( const iterator left,
const iterator right 
)
friend

Determines if two iterators point to the same point in the same sequence.

Parameters
leftFirst iterator to compare.
rightSecond iterator to compare.
Returns
true if left and right point to the same point in the same sequence.

◆ operator!=

template<typename T>
bool operator!= ( const iterator left,
const iterator right 
)
friend

Determines if two iterators point to a different point in perhaps different sequences.

Parameters
leftFirst iterator to compare.
rightSecond iterator to compare.
Returns
true if left does not point to the same point in the sequence as right.
See also
operator==()

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