CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of the interface.
Declared in <llvm/ADT/iterator.h>
template<
typename DerivedT,
typename IteratorCategoryT,
typename T,
typename DifferenceTypeT = std::ptrdiff_t,
typename PointerT = T*,
typename ReferenceT = T&>
class iterator_facade_base;
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.
Iterators are expected to have const rules analogous to pointers, with a single, const-qualified operator*() that returns ReferenceT. This matches the second and third pointers in the following example:
int Value;
{ int *I = &Value; } // ReferenceT 'int&'
{ int *const I = &Value; } // ReferenceT 'int&'; const
{ const int *I = &Value; } // ReferenceT 'const int&'
{ const int *const I = &Value; } // ReferenceT 'const int&'; const
If an iterator facade returns a handle to its own state, then T (and PointerT and ReferenceT) should usually be const-qualified. Otherwise, if clients are expected to modify the handle itself, the field can be declared mutable or use const_cast.
Classes wishing to use iterator_facade_base should implement the following methods:
Forward Iterators: (All of the following methods)
DerivedT &operator=(const DerivedT &R);
bool operator==(const DerivedT &R) const;
T &operator*() const;
DerivedT &operator++();
Bidirectional Iterators: (All methods of forward iterators, plus the following)
DerivedT &operator--();
Random-access Iterators: (All methods of bidirectional iterators excluding the following)
DerivedT &operator++();
DerivedT &operator--(); (and plus the following)
bool operator<(const DerivedT &RHS) const;
DifferenceTypeT operator-(const DerivedT &R) const;
DerivedT &operator+=(DifferenceTypeT N);
DerivedT &operator-=(DifferenceTypeT N);
| Name | Description |
|---|---|
difference_type | Signed type used to express the distance between iterators. |
iterator_category | Iterator category tag for this facade. |
pointer | Pointer type returned by the iterator. |
reference | Reference type returned by the iterator. |
value_type | Value type produced by the iterator. |
| Name | Description |
|---|---|
Unnamed enum | Capability flags for the iterator category. |
| Name | Description |
|---|---|
operator+ | Advance the iterator by n and return the result. |
operator++ | Increment operators |
operator- | Retreat the iterator by n and return the result. |
operator-- | Decrement operators |
operator-> | Return a proxy pointer to the current element. |
operator[] | Return a proxy to the element at offset n. |
operator<= | Return true if this iterator is less than or equal to RHS. |
operator> | Return true if this iterator is greater than RHS. |
operator>= | Return true if this iterator is greater than or equal to RHS. |
| Name | Description |
|---|---|
PointerProxy | Proxy that yields a pointer from a copied reference. |
ReferenceProxy | Proxy that yields a reference from a copied iterator. |
| Name | Description |
|---|---|
llvm::operator+ | Return an iterator n positions after i. |
| Name | Description |
|---|---|
BinaryAnnotationIterator | Forward iterator over compressed inline-site binary annotations. |
CaseItImpl | Iterator over the cases of a SwitchInst. |
CaseIteratorImpl | Random-access iterator over switch cases. |
DbiModuleSourceFilesIterator | Random-access iterator over the source file names of one DBI module. |
FixedStreamArrayIterator | Random-access iterator over the elements of a FixedStreamArray. |
FunctionRecordIterator | Iterator over function records, optionally filtered to a single file. |
HashTableIterator | Forward iterator over the present entries of a PDB HashTable. |
Iterator | Forward iterator over context trie nodes in breadth-first order. |
Iterator | Forward iterator over the non-empty strings stored in the table. |
Iterator | An iterator for all entries in the table. |
LineCoverageIterator | An iterator over the LineCoverageStats objects for lines described by a CoverageData instance. |
MIBundleOperandIteratorBase | Iterator that visits all operands in a bundle of MachineInstrs. |
MemoryInfoIterator | Forward iterator over MemoryInfo entries in a MemoryInfoList stream. |
RepeatedIterator | A random-access iterator that always dereferences to the same value. |
SameNameIterator | An iterator for Entries all having the same string as key. |
SmallSetIterator | SmallSetIterator - This class implements a const_iterator for SmallSet by delegating to the underlying SmallVector or Set iterators. |
SplittingIterator | A forward iterator over partitions of string over a separator. |
SymbolGroupIterator | Forward iterator over SymbolGroup entries in an InputFile. |
VarStreamArrayIterator | Forward iterator over the records of a VarStreamArray. |
attribute_iterator | Forward iterator over the attributes of a single DWARFDie. |
concat_iterator | Iterator wrapper that concatenates sequences together. |
const_child_iterator | Iteration over child cycles, yielding handles. |
const_iterator | Forward iterator over the children of a dominator tree node. |
const_iterator | Path iterator. |
const_iterator | Const forward iterator over nodes in an IntrusiveBackList. |
const_iterator | Yields the index of each set bit, skipping unset bits via countr_zero. |
def_chain_iterator | Forward iterator over the defining-access chain of a MemoryDef or MemoryUse. |
indexed_accessor_iterator | A utility class used to implement an iterator that contains some base object and an index. The iterator moves the index but keeps the base constant. |
iterator | Iterators for registry entries. |
iterator | Bidirectional iterator over the immediate children of a DWARFDie. |
iterator | Random-access iterator over references in an InternalRefArrayRef. |
iterator | An iterator to go through the expression operations. |
iterator | Mutable forward iterator over nodes in an IntrusiveBackList. |
iterator | Input iterator over FunctionId entries in the name table. |
iterator_adaptor_base | CRTP base class for adapting an iterator to a different type. |
location_op_iterator | Bidirectional iterator over debug-info location operands. |
location_op_iterator | Bidirectional iterator over location operands as Value pointers. |
memoryaccess_def_iterator_base | Iterator over the defining accesses of a MemoryAccess. |
nested_collection_iterator | Forward iterator that flattens nested outer/inner collections. |
object_refs_iterator | Iterator for ObjectID. |
phi_iterator_impl | Iterator to walk just the phi nodes in the basic block. |
postorder_ref_scc_iterator | A post-order depth-first RefSCC iterator over the call graph. |
reverse_iterator | Reverse path iterator. |
scc_iterator | Enumerate the SCCs of a directed graph in reverse topological order of the SCC DAG. |
upward_defs_iterator | Iterator that walks defs with a phi-translated memory location. |