Static Value-Flow Analysis
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Types | Friends | List of all members
SVF::iter_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT > Class Template Reference

#include <iterator.h>

Inheritance diagram for SVF::iter_facade_base< DerivedT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT >:
SVF::iter_adaptor_base< mapped_iter< ItTy, FuncTy >, ItTy, std::iterator_traits< ItTy >::iterator_category, std::remove_reference< decltype(std::declval< FuncTy >()(*std::declval< ItTy >())) >::type > SVF::iter_adaptor_base< DerivedT, WrappedIteratorT, IteratorCategoryT, T, DifferenceTypeT, PointerT, ReferenceT > SVF::mapped_iter< ItTy, FuncTy, FuncReturnTy > SVF::pointee_iter< WrappedIteratorT, T > SVF::pointer_iterator< WrappedIteratorT, T >

Classes

class  ReferenceProxy
 

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
 
DerivedToperator++ ()
 
DerivedT operator++ (int)
 
DerivedToperator-- ()
 
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
 
PointerT operator-> ()
 
PointerT 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 SVF::iter_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 iter_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 67 of file iterator.h.

Member Typedef Documentation

◆ difference_type

Definition at line 72 of file iterator.h.

◆ iterator_category

Definition at line 70 of file iterator.h.

◆ pointer

Definition at line 73 of file iterator.h.

◆ reference

Definition at line 74 of file iterator.h.

◆ value_type

Definition at line 71 of file iterator.h.

Member Enumeration Documentation

◆ anonymous enum

Enumerator
IsRandomAccess 
IsBidirectional 

Definition at line 77 of file iterator.h.

78 {
79 IsRandomAccess = std::is_base_of<std::random_access_iterator_tag,
80 IteratorCategoryT>::value,
81 IsBidirectional = std::is_base_of<std::bidirectional_iterator_tag,
82 IteratorCategoryT>::value,
83 };
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

Member Function Documentation

◆ operator!=()

Definition at line 164 of file iterator.h.

165 {
166 return !(static_cast<const DerivedT &>(*this) == RHS);
167 }

◆ operator+()

Definition at line 106 of file iterator.h.

107 {
108 static_assert(std::is_base_of<iter_facade_base, DerivedT>::value,
109 "Must pass the derived type to this template!");
110 static_assert(
112 "The '+' operator is only defined for random access iterators.");
113 DerivedT tmp = *static_cast<const DerivedT *>(this);
114 tmp += n;
115 return tmp;
116 }
cJSON * n
Definition cJSON.cpp:2558

◆ operator++() [1/2]

Definition at line 134 of file iterator.h.

135 {
136 static_assert(std::is_base_of<iter_facade_base, DerivedT>::value,
137 "Must pass the derived type to this template!");
138 return static_cast<DerivedT *>(this)->operator+=(1);
139 }

◆ operator++() [2/2]

Definition at line 140 of file iterator.h.

141 {
142 DerivedT tmp = *static_cast<DerivedT *>(this);
143 ++*static_cast<DerivedT *>(this);
144 return tmp;
145 }

◆ operator-()

Definition at line 124 of file iterator.h.

125 {
126 static_assert(
128 "The '-' operator is only defined for random access iterators.");
129 DerivedT tmp = *static_cast<const DerivedT *>(this);
130 tmp -= n;
131 return tmp;
132 }

◆ operator--() [1/2]

Definition at line 146 of file iterator.h.

147 {
148 static_assert(
150 "The decrement operator is only defined for bidirectional iterators.");
151 return static_cast<DerivedT *>(this)->operator-=(1);
152 }

◆ operator--() [2/2]

Definition at line 153 of file iterator.h.

154 {
155 static_assert(
157 "The decrement operator is only defined for bidirectional iterators.");
158 DerivedT tmp = *static_cast<DerivedT *>(this);
159 --*static_cast<DerivedT *>(this);
160 return tmp;
161 }

◆ operator->() [1/2]

Definition at line 193 of file iterator.h.

194 {
195 return &static_cast<DerivedT *>(this)->operator*();
196 }

◆ operator->() [2/2]

Definition at line 197 of file iterator.h.

198 {
199 return &static_cast<const DerivedT *>(this)->operator*();
200 }

◆ operator<=()

Definition at line 178 of file iterator.h.

179 {
180 static_assert(
182 "Relational operators are only defined for random access iterators.");
183 return !(static_cast<const DerivedT &>(*this) > RHS);
184 }

◆ operator>()

Definition at line 170 of file iterator.h.

171 {
172 static_assert(
174 "Relational operators are only defined for random access iterators.");
175 return !(static_cast<const DerivedT &>(*this) < RHS) &&
176 !(static_cast<const DerivedT &>(*this) == RHS);
177 }

◆ operator>=()

Definition at line 185 of file iterator.h.

186 {
187 static_assert(
189 "Relational operators are only defined for random access iterators.");
190 return !(static_cast<const DerivedT &>(*this) < RHS);
191 }

◆ operator[]() [1/2]

Definition at line 201 of file iterator.h.

202 {
203 static_assert(IsRandomAccess,
204 "Subscripting is only defined for random access iterators.");
205 return ReferenceProxy(static_cast<DerivedT *>(this)->operator+(n));
206 }

◆ operator[]() [2/2]

Definition at line 207 of file iterator.h.

208 {
209 static_assert(IsRandomAccess,
210 "Subscripting is only defined for random access iterators.");
211 return ReferenceProxy(static_cast<const DerivedT *>(this)->operator+(n));
212 }

Friends And Related Symbol Documentation

◆ operator+

Definition at line 117 of file iterator.h.

118 {
119 static_assert(
121 "The '+' operator is only defined for random access iterators.");
122 return i + n;
123 }

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