LLVM  14.0.0git
Classes | Public Types | Public Member Functions | Protected Types | Friends | List of all members
llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT > Class Template Reference

CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of the interface. More...

#include "llvm/ADT/iterator.h"

Inherited by llvm::detail::zip_common< ZipType, Iters >, llvm::detail::zip_common< zip_first< Iters... >, Iters... >, and llvm::detail::zip_common< zip_shortest< Iters... >, Iters... >.

Classes

class  PointerProxy
 A proxy object for computing a pointer via indirecting a copy of a reference. More...
 
class  ReferenceProxy
 A proxy object for computing a reference via indirecting a copy of an iterator. More...
 

Public Types

using iterator_category = IteratorCategoryT
 
using value_type = T
 
using difference_type = DifferenceTypeT
 
using pointer = PointerT
 
using reference = ReferenceT
 

Public Member Functions

DerivedT operator+ (DifferenceTypeT n) const
 
DerivedT operator- (DifferenceTypeT n) const
 
DerivedT & operator++ ()
 
DerivedT operator++ (int)
 
DerivedT & operator-- ()
 
DerivedT operator-- (int)
 
bool operator!= (const DerivedT &RHS) const
 
bool operator> (const DerivedT &RHS) const
 
bool operator<= (const DerivedT &RHS) const
 
bool operator>= (const DerivedT &RHS) const
 
PointerProxy operator-> ()
 
PointerProxy operator-> () const
 
ReferenceProxy operator[] (DifferenceTypeT n)
 
ReferenceProxy operator[] (DifferenceTypeT n) const
 

Protected Types

enum  { IsRandomAccess, IsBidirectional }
 

Friends

DerivedT operator+ (DifferenceTypeT n, const DerivedT &i)
 

Detailed Description

template<typename DerivedT, typename IteratorCategoryT, typename T, typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
class llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >

CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of the interface.

Use this when it is reasonable to implement most of the iterator functionality in terms of a core subset. If you need special behavior or there are performance implications for this, you may want to override the relevant members instead.

Note, one abstraction that this does not provide is implementing subtraction in terms of addition by negating the difference. Negation isn't always information preserving, and I can see very reasonable iterator designs where this doesn't work well. It doesn't really force much added boilerplate anyways.

Another abstraction that this doesn't provide is implementing increment in terms of addition of one. These aren't equivalent for all iterator categories, and respecting that adds a lot of complexity for little gain.

Classes wishing to use iterator_facade_base should implement the following methods:

Forward Iterators: (All of the following methods)

Bidirectional Iterators: (All methods of forward iterators, plus the following)

Random-access Iterators: (All methods of bidirectional iterators excluding the following)

Definition at line 66 of file iterator.h.

Member Typedef Documentation

◆ difference_type

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
using llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::difference_type = DifferenceTypeT

Definition at line 70 of file iterator.h.

◆ iterator_category

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
using llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::iterator_category = IteratorCategoryT

Definition at line 68 of file iterator.h.

◆ pointer

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
using llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::pointer = PointerT

Definition at line 71 of file iterator.h.

◆ reference

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
using llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::reference = ReferenceT

Definition at line 72 of file iterator.h.

◆ value_type

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
using llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::value_type = T

Definition at line 69 of file iterator.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
anonymous enum
protected
Enumerator
IsRandomAccess 
IsBidirectional 

Definition at line 75 of file iterator.h.

Member Function Documentation

◆ operator!=()

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
bool llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator!= ( const DerivedT &  RHS) const
inline

Definition at line 166 of file iterator.h.

◆ operator+()

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
DerivedT llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator+ ( DifferenceTypeT  n) const
inline

Definition at line 115 of file iterator.h.

◆ operator++() [1/2]

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
DerivedT& llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator++ ( )
inline

Definition at line 140 of file iterator.h.

◆ operator++() [2/2]

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
DerivedT llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator++ ( int  )
inline

Definition at line 145 of file iterator.h.

◆ operator-()

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
DerivedT llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator- ( DifferenceTypeT  n) const
inline

Definition at line 131 of file iterator.h.

◆ operator--() [1/2]

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
DerivedT& llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator-- ( )
inline

Definition at line 150 of file iterator.h.

◆ operator--() [2/2]

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
DerivedT llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator-- ( int  )
inline

Definition at line 156 of file iterator.h.

◆ operator->() [1/2]

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
PointerProxy llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator-> ( )
inline

Definition at line 191 of file iterator.h.

◆ operator->() [2/2]

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
PointerProxy llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator-> ( ) const
inline

Definition at line 194 of file iterator.h.

◆ operator<=()

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
bool llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator<= ( const DerivedT &  RHS) const
inline

Definition at line 178 of file iterator.h.

◆ operator>()

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
bool llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator> ( const DerivedT &  RHS) const
inline

Definition at line 171 of file iterator.h.

◆ operator>=()

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
bool llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator>= ( const DerivedT &  RHS) const
inline

Definition at line 184 of file iterator.h.

◆ operator[]() [1/2]

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
ReferenceProxy llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator[] ( DifferenceTypeT  n)
inline

Definition at line 197 of file iterator.h.

◆ operator[]() [2/2]

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
ReferenceProxy llvm::iterator_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >::operator[] ( DifferenceTypeT  n) const
inline

Definition at line 202 of file iterator.h.

Friends And Related Function Documentation

◆ operator+

template<typename DerivedT , typename IteratorCategoryT , typename T , typename DifferenceTypeT = std::ptrdiff_t, typename PointerT = T *, typename ReferenceT = T &>
DerivedT operator+ ( DifferenceTypeT  n,
const DerivedT &  i 
)
friend

Definition at line 125 of file iterator.h.


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