Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace boost::iterator_facade with explicit implementation for SdfPathTable #2534

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions pxr/usd/sdf/pathTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#include "pxr/base/tf/pointerAndBits.h"
#include "pxr/base/tf/functionRef.h"

#include <boost/iterator/iterator_facade.hpp>

#include <algorithm>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -202,21 +200,49 @@ class SdfPathTable
// iterators. Currently only forward traversal is supported.
template <class, class> friend class Iterator;
template <class ValType, class EntryPtr>
class Iterator :
public boost::iterator_facade<Iterator<ValType, EntryPtr>,
ValType, boost::forward_traversal_tag>
class Iterator
{
public:
using iterator_category = std::forward_iterator_tag;
using value_type = ValType;
using reference = ValType&;
using pointer = ValType*;
using difference_type = std::ptrdiff_t;

/// The standard requires default construction but places practically no
/// requirements on the semantics of default-constructed iterators.
Iterator() {}
Iterator() = default;

/// Copy constructor (also allows for converting non-const to const).
template <class OtherVal, class OtherEntryPtr>
Iterator(Iterator<OtherVal, OtherEntryPtr> const &other)
: _entry(other._entry)
{}

reference operator*() const { return dereference(); }
pointer operator->() const { return &(dereference()); }

Iterator& operator++() {
increment();
return *this;
}

Iterator operator++(int) {
Iterator result(*this);
increment();
return result;
}

template <class OtherVal, class OtherEntryPtr>
bool operator==(Iterator<OtherVal, OtherEntryPtr> const &other) const {
return equal(other);
}

template <class OtherVal, class OtherEntryPtr>
bool operator!=(Iterator<OtherVal, OtherEntryPtr> const &other) const {
return !equal(other);
}

/// Return an iterator \a e, defining a maximal range [\a *this, \a e)
/// such that for all \a i in the range, \a i->first is \a
/// (*this)->first or is prefixed by \a (*this)->first.
Expand Down Expand Up @@ -248,16 +274,13 @@ class SdfPathTable
}

protected:
friend class boost::iterator_core_access;
friend class SdfPathTable;
template <class, class> friend class Iterator;

explicit Iterator(EntryPtr entry)
: _entry(entry) {}

// Fundamental functionality to implement the iterator.
// boost::iterator_facade will invoke these as necessary to implement
// the full iterator public interface.

// Iterator increment.
inline void increment() {
Expand Down