Skip to content

Commit

Permalink
Replace boost::variant with std::variant in usdGeom
Browse files Browse the repository at this point in the history
  • Loading branch information
nvmkuruc committed Sep 20, 2023
1 parent ad4d31f commit 37fa325
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 14 additions & 15 deletions pxr/usd/usdGeom/xformOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@
#include "pxr/usd/usdGeom/tokens.h"

#include <string>
#include <variant>
#include <vector>
#include <typeinfo>

#include <boost/variant.hpp>

#include "pxr/base/tf/staticTokens.h"

PXR_NAMESPACE_OPEN_SCOPE
Expand Down Expand Up @@ -315,7 +314,7 @@ class UsdGeomXformOp
/// The determination is based on a snapshot of the authored state of the
/// op, and may become invalid in the face of further authoring.
bool MightBeTimeVarying() const {
return boost::apply_visitor(_GetMightBeTimeVarying(), _attr);
return std::visit(_GetMightBeTimeVarying(), _attr);
}

// ---------------------------------------------------------------
Expand All @@ -329,7 +328,7 @@ class UsdGeomXformOp

/// Explicit UsdAttribute extractor
UsdAttribute const &GetAttr() const {
return boost::apply_visitor(_GetAttr(), _attr);
return std::visit(_GetAttr(), _attr);
}

/// Return true if the wrapped UsdAttribute::IsDefined(), and in
Expand Down Expand Up @@ -381,7 +380,7 @@ class UsdGeomXformOp
///
template <typename T>
bool Get(T* value, UsdTimeCode time = UsdTimeCode::Default()) const {
return boost::apply_visitor(_Get<T>(value, time), _attr);
return std::visit(_Get<T>(value, time), _attr);
}

/// Set the attribute value of the XformOp at \p time
Expand All @@ -407,20 +406,20 @@ class UsdGeomXformOp
/// Populates the list of time samples at which the associated attribute
/// is authored.
bool GetTimeSamples(std::vector<double> *times) const {
return boost::apply_visitor(_GetTimeSamples(times), _attr);
return std::visit(_GetTimeSamples(times), _attr);
}

/// Populates the list of time samples within the given \p interval,
/// at which the associated attribute is authored.
bool GetTimeSamplesInInterval(const GfInterval &interval,
std::vector<double> *times) const {
return boost::apply_visitor(
return std::visit(
_GetTimeSamplesInInterval(interval, times), _attr);
}

/// Returns the number of time samples authored for this xformOp.
size_t GetNumTimeSamples() const {
return boost::apply_visitor(_GetNumTimeSamples(), _attr);
return std::visit(_GetNumTimeSamples(), _attr);
}

private:
Expand Down Expand Up @@ -488,14 +487,14 @@ class UsdGeomXformOp
// Hence, access to the creation of an attribute query is restricted inside
// a private member function named _CreateAttributeQuery().
//
mutable boost::variant<UsdAttribute, UsdAttributeQuery> _attr;
mutable std::variant<UsdAttribute, UsdAttributeQuery> _attr;

Type _opType;
bool _isInverseOp;

// Visitor for getting xformOp value.
template <class T>
struct _Get : public boost::static_visitor<bool>
struct _Get
{
_Get(T *value_,
UsdTimeCode time_ = UsdTimeCode::Default()) : value (value_), time(time_)
Expand All @@ -516,7 +515,7 @@ class UsdGeomXformOp
};

// Visitor for getting a const-reference to the UsdAttribute.
struct _GetAttr : public boost::static_visitor<const UsdAttribute &> {
struct _GetAttr {

_GetAttr() {}

Expand All @@ -532,7 +531,7 @@ class UsdGeomXformOp
};

// Visitor for getting all the time samples.
struct _GetTimeSamples : public boost::static_visitor<bool> {
struct _GetTimeSamples {

_GetTimeSamples(std::vector<double> *times_) : times(times_) {}

Expand All @@ -550,7 +549,7 @@ class UsdGeomXformOp
};

// Visitor for getting all the time samples within a given interval.
struct _GetTimeSamplesInInterval : public boost::static_visitor<bool> {
struct _GetTimeSamplesInInterval {

_GetTimeSamplesInInterval(const GfInterval &interval_,
std::vector<double> *times_)
Expand All @@ -572,7 +571,7 @@ class UsdGeomXformOp
};

// Visitor for getting the number of time samples.
struct _GetNumTimeSamples : public boost::static_visitor<size_t> {
struct _GetNumTimeSamples {

_GetNumTimeSamples() {}

Expand All @@ -588,7 +587,7 @@ class UsdGeomXformOp
};

// Visitor for determining whether the op might vary over time.
struct _GetMightBeTimeVarying : public boost::static_visitor<bool> {
struct _GetMightBeTimeVarying {

_GetMightBeTimeVarying() {}

Expand Down
2 changes: 1 addition & 1 deletion pxr/usd/usdGeom/xformable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ UsdGeomXformable::XformQuery::GetTimeSamplesInInterval(
// This should never throw and exception because XformQuery's constructor
// initializes an attribute query for all its xformOps.
const UsdAttributeQuery &attrQuery =
boost::get<UsdAttributeQuery>(xformOp._attr);
std::get<UsdAttributeQuery>(xformOp._attr);
xformOpAttrQueries.push_back(attrQuery);
}

Expand Down

0 comments on commit 37fa325

Please sign in to comment.