diff --git a/pxr/usd/sdf/namespaceEdit.cpp b/pxr/usd/sdf/namespaceEdit.cpp index c8b0d4c450..fcc48c59c2 100644 --- a/pxr/usd/sdf/namespaceEdit.cpp +++ b/pxr/usd/sdf/namespaceEdit.cpp @@ -31,10 +31,10 @@ #include "pxr/base/tf/stringUtils.h" #include -#include #include #include +#include PXR_NAMESPACE_OPEN_SCOPE @@ -91,7 +91,7 @@ class SdfNamespaceEdit_Namespace { // A key for a _Node. _RootKey is for the root, SdfPath is for attribute // connections and relationship targets, and TfToken for prim and property // children. - typedef boost::variant<_RootKey, TfToken, SdfPath> _Key; + using _Key = std::variant<_RootKey, TfToken, SdfPath>; struct _TargetKey { _TargetKey(const SdfPath& path) : key(path) { } @@ -161,7 +161,7 @@ class SdfNamespaceEdit_Namespace { // Test if the node was removed. This returns true for key nodes. bool IsRemoved() const { - return !_parent && _key.which() != 0; + return !_parent && _key.index() != 0; } // Remove the node from its parent. After this call returns \c true @@ -567,7 +567,7 @@ SdfNamespaceEdit_Namespace::_FixBackpointers( for (_BackpointerMap::iterator j = i; j != n; ++j) { for (auto node : j->second) { node->SetKey( - boost::get(node->GetKey()). + std::get(node->GetKey()). ReplacePrefix(currentPath, newPath, !fixTargetPaths)); } } diff --git a/pxr/usd/sdf/parserHelpers.h b/pxr/usd/sdf/parserHelpers.h index 52527acf43..8c2909f5e7 100644 --- a/pxr/usd/sdf/parserHelpers.h +++ b/pxr/usd/sdf/parserHelpers.h @@ -31,12 +31,13 @@ #include "pxr/base/vt/value.h" #include -#include +#include #include #include #include #include +#include #include PXR_NAMESPACE_OPEN_SCOPE @@ -46,8 +47,8 @@ bool Sdf_BoolFromString(const std::string &, bool *parseOk); namespace Sdf_ParserHelpers { // Internal variant type. -typedef boost::variant _Variant; +using _Variant = std::variant; //////////////////////////////////////////////////////////////////////// // Utilities that implement the Sdf_ParserHelpers::Value::Get() method. The @@ -61,7 +62,7 @@ struct _GetImpl { typedef const T &ResultType; static const T &Visit(_Variant const &variant) { - return boost::get(variant); + return std::get(variant); } }; @@ -72,12 +73,11 @@ struct _GetImpl template struct _GetImpl< T, std::enable_if_t::value>> - : public boost::static_visitor { typedef T ResultType; T Visit(_Variant const &variant) { - return boost::apply_visitor(*this, variant); + return std::visit(*this, variant); } // Fallback case: throw bad_get. @@ -114,12 +114,11 @@ struct _GetImpl< template struct _GetImpl< T, std::enable_if_t::value>> - : public boost::static_visitor { typedef T ResultType; T Visit(_Variant const &variant) { - return boost::apply_visitor(*this, variant); + return std::visit(*this, variant); } // Fallback case: throw bad_get. @@ -167,9 +166,9 @@ struct _GetImpl typedef SdfAssetPath ResultType; SdfAssetPath Visit(_Variant const &variant) { - if (std::string const *str = boost::get(&variant)) + if (std::string const *str = std::get_if(&variant)) return SdfAssetPath(*str); - return boost::get(variant); + return std::get(variant); } }; @@ -177,12 +176,12 @@ struct _GetImpl // Strings and tokens get parsed via Sdf_BoolFromString. Otherwise throw // bad_get. template <> -struct _GetImpl : public boost::static_visitor +struct _GetImpl { typedef bool ResultType; bool Visit(_Variant const &variant) { - return boost::apply_visitor(*this, variant); + return std::visit(*this, variant); } // Parse string via Sdf_BoolFromString. @@ -270,33 +269,37 @@ struct Value // boost::bad_get. template typename _GetImpl::ResultType Get() const { - return _GetImpl().Visit(_variant); + try { + return _GetImpl().Visit(_variant); + } catch (std::bad_variant_access& e) { + throw boost::bad_get(); + } } // Hopefully short-lived API that applies an external visitor to the held // variant type. template - typename Visitor::result_type + auto ApplyVisitor(const Visitor &visitor) { - return boost::apply_visitor(visitor, _variant); + return std::visit(visitor, _variant); } template - typename Visitor::result_type + auto ApplyVisitor(Visitor &visitor) { - return boost::apply_visitor(visitor, _variant); + return std::visit(visitor, _variant); } template - typename Visitor::result_type + auto ApplyVisitor(const Visitor &visitor) const { - return _variant.apply_visitor(visitor); + return std::visit(visitor, _variant); } template - typename Visitor::result_type + auto ApplyVisitor(Visitor &visitor) const { - return _variant.apply_visitor(visitor); + return std::visit(visitor, _variant); } private: diff --git a/pxr/usd/sdf/parserValueContext.cpp b/pxr/usd/sdf/parserValueContext.cpp index 56af0a5895..864df22c99 100644 --- a/pxr/usd/sdf/parserValueContext.cpp +++ b/pxr/usd/sdf/parserValueContext.cpp @@ -30,7 +30,7 @@ PXR_NAMESPACE_OPEN_SCOPE -struct Sdf_ToStringVisitor : boost::static_visitor +struct Sdf_ToStringVisitor { template std::string operator () (const T &value)