24 #ifndef PXR_BASE_TF_ITERATOR_H
25 #define PXR_BASE_TF_ITERATOR_H
36 #include <type_traits>
52 template <
class T,
bool Reverse>
59 template <
class T,
bool Reverse>
175 template <
class T,
bool Reverse=false>
179 struct _IteratorPairAndCopy;
180 struct _IteratorPair;
184 typedef typename std::conditional<
186 _IteratorPairAndCopy, _IteratorPair
211 "TfIterator only allows rvalues that it has been told to copy "
212 "via Tf_ShouldIterateOverCopy");
228 return _data.current == _data.end;
236 return _data.current == iterator._data.current;
242 return !(*
this == iterator);
272 return *_data.current;
280 return *_data.current;
288 return _data.current;
293 explicit operator bool()
const {
294 return !(_data.current == _data.end);
301 return _data.current;
308 return _data.current;
323 struct _IteratorPair {
325 explicit _IteratorPair(
T &
c) {
332 current(b),
end(e) {}
339 struct _IteratorPairAndCopy :
public _IteratorPair {
340 _IteratorPairAndCopy() {}
341 explicit _IteratorPairAndCopy(
T const &
c) : _IteratorPair(), _copy(c) {
345 using _IteratorPair::current;
362 std::forward<T>(container));
370 std::forward<T>(container));
390 #define TF_FOR_ALL(iter, c) \
391 for (auto iter = TfMakeIterator(c); iter; ++iter)
399 #define TF_REVERSE_FOR_ALL(iter, c) \
400 for (auto iter = TfMakeReverseIterator(c); iter; ++iter)
406 template <
class T,
size_t N>
418 template <
typename UnderlyingIterator>
420 private std::reverse_iterator<UnderlyingIterator> {
423 using ReverseIterator = std::reverse_iterator<UnderlyingIterator>;
424 const ReverseIterator& _reverse_iterator()
const {
return *
this; }
425 ReverseIterator& _reverse_iterator() {
return *
this; }
427 : ReverseIterator(it) {}
429 : ReverseIterator(it) {}
439 "Tf_ProxyReferenceReverseIterator should only be used "
440 "when the underlying iterator's reference type is a "
441 "proxy (MyTypeRef) and not a true reference (MyType&)."
442 "Use std::reverse_iterator instead.");
444 std::random_access_iterator_tag>::
value,
445 "Tf_ProxyReferenceReverseIterator must wrap a random "
450 ReverseIterator(it) {
455 using ReverseIterator::base;
456 using ReverseIterator::operator*;
457 using ReverseIterator::operator[];
466 ++_reverse_iterator();
472 ++_reverse_iterator();
477 --_reverse_iterator();
483 --_reverse_iterator();
495 template <
typename OtherIt>
498 return _reverse_iterator() - other._reverse_iterator();
502 _reverse_iterator() += increment;
507 _reverse_iterator() -= decrement;
515 increment + iterator._reverse_iterator());
519 template <
typename OtherIt>
522 return lhs._reverse_iterator() == rhs._reverse_iterator();
525 template <
typename OtherIt>
528 return lhs._reverse_iterator() != rhs._reverse_iterator();
531 template <
typename OtherIt>
534 return lhs._reverse_iterator() < rhs._reverse_iterator();
537 template <
typename OtherIt>
540 return lhs._reverse_iterator() > rhs._reverse_iterator();
543 template <
typename OtherIt>
546 return lhs._reverse_iterator() <= rhs._reverse_iterator();
549 template <
typename OtherIt>
552 return lhs._reverse_iterator() >= rhs._reverse_iterator();
558 #endif // PXR_BASE_TF_ITERATOR_H
TfIterator< typename std::remove_reference< T >::type, true > TfMakeReverseIterator(T &&container)
pointer operator->() const
TfIterator GetNext() const
typename ReverseIterator::iterator_category iterator_category
static IteratorType Begin(T &c)
constexpr size_t TfArraySize(const T(&array)[N]) noexcept
Tf_ProxyReferenceReverseIterator & operator-=(difference_type decrement)
GLsizei const GLfloat * value
bool operator!=(const TfIterator &iterator) const
friend bool operator<(const Tf_ProxyReferenceReverseIterator &lhs, const Tf_ProxyReferenceReverseIterator< OtherIt > &rhs)
TfIterator()
Default constructor. This iterator is uninitialized.
TfIterator(Iterator const &begin, Iterator const &end)
Tf_ProxyReferenceReverseIterator(UnderlyingIterator it)
typename ReverseIterator::difference_type difference_type
**But if you need a result
friend bool operator>=(const Tf_ProxyReferenceReverseIterator &lhs, const Tf_ProxyReferenceReverseIterator< OtherIt > &rhs)
TfIterator(T &&container)
Allow rvalues only if the container type T should be copied by TfIterator.
typename ReverseIterator::pointer pointer
typename ReverseIterator::value_type value_type
Tf_ProxyReferenceReverseIterator & operator+=(difference_type increment)
const Iterator & base() const
static IteratorType Begin(T const &c)
static IteratorType End(T const &c)
Tf_ProxyReferenceReverseIterator operator-(difference_type decrement) const
static IteratorType End(T &c)
bool operator==(const TfIterator &iterator) const
Tf_ProxyReferenceReverseIterator()=default
Tf_ProxyReferenceReverseIterator operator+(difference_type increment) const
T::reverse_iterator IteratorType
Tf_ProxyReferenceReverseIterator & operator++()
typename ReverseIterator::iterator_type iterator_type
GLboolean GLboolean GLboolean b
friend Tf_ProxyReferenceReverseIterator operator+(const difference_type increment, const Tf_ProxyReferenceReverseIterator &iterator)
friend bool operator==(const Tf_ProxyReferenceReverseIterator &lhs, const Tf_ProxyReferenceReverseIterator< OtherIt > &rhs)
friend bool operator<=(const Tf_ProxyReferenceReverseIterator &lhs, const Tf_ProxyReferenceReverseIterator< OtherIt > &rhs)
std::iterator_traits< Iterator >::reference Reference
static IteratorType Begin(T &c)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
static IteratorType Begin(T const &c)
Reference operator*() const
Tf_ProxyReferenceReverseIterator operator++(int)
Tf_ProxyReferenceReverseIterator operator--(int)
static IteratorType End(T &c)
Tf_ProxyReferenceReverseIterator & operator--()
TfIterator & operator++()
friend bool operator>(const Tf_ProxyReferenceReverseIterator &lhs, const Tf_ProxyReferenceReverseIterator< OtherIt > &rhs)
TfIterator operator++(int)
#define PXR_NAMESPACE_CLOSE_SCOPE
GA_API const UT_StringHolder N
static IteratorType End(T const &c)
typename ReverseIterator::reference reference
Tf_IteratorInterface< T, Reverse > IterInterface
difference_type operator-(const Tf_ProxyReferenceReverseIterator< OtherIt > &other) const
T::const_iterator IteratorType
IterInterface::IteratorType Iterator
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate and *a name There is also one special expression reference
T::const_reverse_iterator IteratorType
TfIterator< typename std::remove_reference< T >::type > TfMakeIterator(T &&container)
friend bool operator!=(const Tf_ProxyReferenceReverseIterator &lhs, const Tf_ProxyReferenceReverseIterator< OtherIt > &rhs)
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.