9#ifndef LLVM_ADT_ITERATOR_H
10#define LLVM_ADT_ITERATOR_H
77template <
typename DerivedT,
typename IteratorCategoryT,
typename T,
78 typename DifferenceTypeT = std::ptrdiff_t,
typename PointerT =
T *,
79 typename ReferenceT =
T &>
109 operator ReferenceT()
const {
return *
I; }
121 template <
typename RefT>
130 static_assert(std::is_base_of<iterator_facade_base, DerivedT>::value,
131 "Must pass the derived type to this template!");
134 "The '+' operator is only defined for random access iterators.");
135 DerivedT tmp = *
static_cast<const DerivedT *
>(
this);
139 friend DerivedT
operator+(DifferenceTypeT n,
const DerivedT &i) {
142 "The '+' operator is only defined for random access iterators.");
148 "The '-' operator is only defined for random access iterators.");
149 DerivedT tmp = *
static_cast<const DerivedT *
>(
this);
155 static_assert(std::is_base_of<iterator_facade_base, DerivedT>::value,
156 "Must pass the derived type to this template!");
157 return static_cast<DerivedT *
>(
this)->
operator+=(1);
160 DerivedT tmp = *
static_cast<DerivedT *
>(
this);
161 ++*
static_cast<DerivedT *
>(
this);
167 "The decrement operator is only defined for bidirectional iterators.");
168 return static_cast<DerivedT *
>(
this)->
operator-=(1);
173 "The decrement operator is only defined for bidirectional iterators.");
174 DerivedT tmp = *
static_cast<DerivedT *
>(
this);
175 --*
static_cast<DerivedT *
>(
this);
179#ifndef __cpp_impl_three_way_comparison
181 return !(
static_cast<const DerivedT &
>(*this) ==
RHS);
188 "Relational operators are only defined for random access iterators.");
189 return !(
static_cast<const DerivedT &
>(*this) <
RHS) &&
190 !(
static_cast<const DerivedT &
>(*
this) ==
RHS);
195 "Relational operators are only defined for random access iterators.");
196 return !(
static_cast<const DerivedT &
>(*this) >
RHS);
201 "Relational operators are only defined for random access iterators.");
202 return !(
static_cast<const DerivedT &
>(*this) <
RHS);
206 return static_cast<const DerivedT *
>(
this)->
operator*();
210 "Subscripting is only defined for random access iterators.");
211 return static_cast<const DerivedT *
>(
this)->
operator+(n);
222 typename IteratorCategoryT =
223 typename std::iterator_traits<WrappedIteratorT>::iterator_category,
224 typename T =
typename std::iterator_traits<WrappedIteratorT>::value_type,
225 typename DifferenceTypeT =
226 typename std::iterator_traits<WrappedIteratorT>::difference_type,
227 typename PointerT = std::conditional_t<
228 std::is_same<
T,
typename std::iterator_traits<
230 typename std::iterator_traits<WrappedIteratorT>::pointer,
T *>,
231 typename ReferenceT = std::conditional_t<
232 std::is_same<
T,
typename std::iterator_traits<
234 typename std::iterator_traits<WrappedIteratorT>::reference,
T &>>
237 DifferenceTypeT, PointerT, ReferenceT> {
238 using BaseT =
typename iterator_adaptor_base::iterator_facade_base;
246 static_assert(std::is_base_of<iterator_adaptor_base, DerivedT>::value,
247 "Must pass the derived type to this template!");
257 BaseT::IsRandomAccess,
258 "The '+=' operator is only defined for random access iterators.");
260 return *
static_cast<DerivedT *
>(
this);
264 BaseT::IsRandomAccess,
265 "The '-=' operator is only defined for random access iterators.");
267 return *
static_cast<DerivedT *
>(
this);
269 using BaseT::operator-;
272 BaseT::IsRandomAccess,
273 "The '-' operator is only defined for random access iterators.");
279 using BaseT::operator++;
282 return *
static_cast<DerivedT *
>(
this);
284 using BaseT::operator--;
287 BaseT::IsBidirectional,
288 "The decrement operator is only defined for bidirectional iterators.");
290 return *
static_cast<DerivedT *
>(
this);
300 BaseT::IsRandomAccess,
301 "Relational operators are only defined for random access iterators.");
318 typename T = std::remove_reference_t<
decltype(
319 **std::declval<WrappedIteratorT>())>>
323 typename std::iterator_traits<WrappedIteratorT>::iterator_category,
326 template <
typename U>
334 decltype(std::begin(std::declval<RangeT>()))>
335iterator_range<pointee_iterator<WrappedIteratorT>>
338 return make_range(PointeeIteratorT(std::begin(std::forward<RangeT>(
Range))),
339 PointeeIteratorT(std::end(std::forward<RangeT>(
Range))));
343 typename T =
decltype(&*std::declval<WrappedIteratorT>())>
347 typename std::iterator_traits<WrappedIteratorT>::iterator_category,
361 decltype(std::begin(std::declval<RangeT>()))>
362iterator_range<pointer_iterator<WrappedIteratorT>>
365 return make_range(PointerIteratorT(std::begin(std::forward<RangeT>(
Range))),
366 PointerIteratorT(std::end(std::forward<RangeT>(
Range))));
370 typename T1 = std::remove_reference_t<
decltype(
371 **std::declval<WrappedIteratorT>())>,
372 typename T2 = std::add_pointer_t<T1>>
Given that RA is a live value
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
const MachineOperand & RHS
CRTP base class for adapting an iterator to a different type.
iterator_adaptor_base(WrappedIteratorT u)
const WrappedIteratorT & wrapped() const
DerivedT & operator+=(difference_type n)
iterator_adaptor_base()=default
difference_type operator-(const DerivedT &RHS) const
friend bool operator<(const iterator_adaptor_base &LHS, const iterator_adaptor_base &RHS)
DerivedT & operator-=(difference_type n)
friend bool operator==(const iterator_adaptor_base &LHS, const iterator_adaptor_base &RHS)
ReferenceT operator*() const
DifferenceTypeT difference_type
A proxy object for computing a pointer via indirecting a copy of a reference.
PointerT operator->() const
A proxy object for computing a reference via indirecting a copy of an iterator.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
PointerProxy operator->() const
IteratorCategoryT iterator_category
bool operator<=(const DerivedT &RHS) const
bool operator>=(const DerivedT &RHS) const
DerivedT operator-(DifferenceTypeT n) const
friend DerivedT operator+(DifferenceTypeT n, const DerivedT &i)
DifferenceTypeT difference_type
bool operator!=(const DerivedT &RHS) const
bool operator>(const DerivedT &RHS) const
DerivedT operator+(DifferenceTypeT n) const
ReferenceProxy operator[](DifferenceTypeT n) const
pointer_iterator(WrappedIteratorT u)
pointer_iterator()=default
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
iterator_range< pointee_iterator< WrappedIteratorT > > make_pointee_range(RangeT &&Range)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
Implement std::hash so that hash_code can be used in STL containers.
An iterator type that allows iterating over the pointees via some other iterator.
pointee_iterator()=default