diff --git a/pxr/usd/usd/primData.h b/pxr/usd/usd/primData.h index 785422b702..b7031f3b6b 100644 --- a/pxr/usd/usd/primData.h +++ b/pxr/usd/usd/primData.h @@ -41,7 +41,6 @@ #include "pxr/usd/sdf/path.h" #include -#include #include #include @@ -353,31 +352,53 @@ class Usd_PrimData }; // Sibling iterator class. -class Usd_PrimDataSiblingIterator : public boost::iterator_adaptor< - Usd_PrimDataSiblingIterator, // crtp. - Usd_PrimData *, // base iterator. - Usd_PrimData *, // value. - boost::forward_traversal_tag, // traversal. - Usd_PrimData * // reference. - > -{ +class Usd_PrimDataSiblingIterator { + using _UnderylingIterator = Usd_PrimData*; public: + using iterator_category = std::forward_iterator_tag; + using value_type = Usd_PrimData*; + using reference = Usd_PrimData*; + using pointer = void; + using difference_type = std::ptrdiff_t; + // Default ctor. - Usd_PrimDataSiblingIterator() {} + Usd_PrimDataSiblingIterator() = default; + + reference operator*() const { return _underlyingIterator; } + + // pre-increment + Usd_PrimDataSiblingIterator& operator++() { + increment(); + return *this; + } + + // post-increment + Usd_PrimDataSiblingIterator operator++(int) { + Usd_PrimDataSiblingIterator result = *this; + increment(); + return result; + } + + bool operator==(const Usd_PrimDataSiblingIterator& other) const { + return _underlyingIterator == other._underlyingIterator; + } + + bool operator!=(const Usd_PrimDataSiblingIterator& other) const { + return _underlyingIterator != other._underlyingIterator; + } private: friend class Usd_PrimData; // Constructor used by Prim. - Usd_PrimDataSiblingIterator(const base_type &i) - : iterator_adaptor_(i) {} + Usd_PrimDataSiblingIterator(const _UnderylingIterator &i) + : _underlyingIterator(i) {} - // Core primitives implementation. - friend class boost::iterator_core_access; - reference dereference() const { return base(); } void increment() { - base_reference() = base_reference()->GetNextSibling(); + _underlyingIterator = _underlyingIterator->GetNextSibling(); } + + _UnderylingIterator _underlyingIterator = nullptr; }; // Sibling range. @@ -412,33 +433,56 @@ Usd_PrimData::_GetChildrenRange() const // Tree iterator class. -class Usd_PrimDataSubtreeIterator : public boost::iterator_adaptor< - Usd_PrimDataSubtreeIterator, // crtp. - Usd_PrimData *, // base iterator. - Usd_PrimData *, // value. - boost::forward_traversal_tag, // traversal. - Usd_PrimData * // reference. - > -{ +class Usd_PrimDataSubtreeIterator { + using _UnderlyingIterator = Usd_PrimData*; public: + using iterator_category = std::forward_iterator_tag; + using value_type = Usd_PrimData*; + using reference = Usd_PrimData*; + using pointer = void; + using difference_type = std::ptrdiff_t; + // Default ctor. - Usd_PrimDataSubtreeIterator() {} + Usd_PrimDataSubtreeIterator() = default; + + reference operator*() const { return _underlyingIterator; } + + // pre-increment + Usd_PrimDataSubtreeIterator& operator++() { + increment(); + return *this; + } + + // post-increment + Usd_PrimDataSubtreeIterator operator++(int) { + Usd_PrimDataSubtreeIterator result = *this; + increment(); + return result; + } + + bool operator==(const Usd_PrimDataSubtreeIterator& other) const { + return _underlyingIterator == other._underlyingIterator; + } + + bool operator!=(const Usd_PrimDataSubtreeIterator& other) const { + return _underlyingIterator != other._underlyingIterator; + } private: friend class Usd_PrimData; friend class UsdPrimSubtreeIterator; // Constructor used by Prim. - Usd_PrimDataSubtreeIterator(const base_type &i) - : iterator_adaptor_(i) {} + Usd_PrimDataSubtreeIterator(const _UnderlyingIterator &i) + : _underlyingIterator(i) {} - // Core primitives implementation. - friend class boost::iterator_core_access; - reference dereference() const { return base(); } void increment() { - base_type &b = base_reference(); - b = b->GetFirstChild() ? b->GetFirstChild() : b->GetNextPrim(); + _underlyingIterator = _underlyingIterator->GetFirstChild() ? + _underlyingIterator->GetFirstChild() : + _underlyingIterator->GetNextPrim(); } + + _UnderlyingIterator _underlyingIterator = nullptr; }; // Tree range.