From d49cdf5fef9ad5ea066b9fdecbe42a20d599d4a5 Mon Sep 17 00:00:00 2001 From: Matt Kuruc Date: Tue, 5 Sep 2023 20:51:49 -0700 Subject: [PATCH] Replace `boost::variant` with `std::variant` in `pxr/base/tf` --- pxr/base/tf/envSetting.cpp | 9 ++++----- pxr/base/tf/wrapEnvSetting.cpp | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pxr/base/tf/envSetting.cpp b/pxr/base/tf/envSetting.cpp index 3f2b43b1a9..fe6d20cef6 100644 --- a/pxr/base/tf/envSetting.cpp +++ b/pxr/base/tf/envSetting.cpp @@ -40,9 +40,8 @@ #include "pxr/base/tf/pyUtils.h" #endif // PXR_PYTHON_SUPPORT_ENABLED -#include -#include #include +#include using std::string; @@ -119,7 +118,7 @@ class Tf_EnvSettingRegistry { TfRegistryManager::GetInstance().SubscribeTo(); } - using VariantType = boost::variant; + using VariantType = std::variant; template bool Define(string const& varName, @@ -141,7 +140,7 @@ class Tf_EnvSettingRegistry { TfHashMap::iterator it; std::tie(it, inserted) = _valuesByName.insert({varName, value}); - U* entryPointer = boost::get(&(it->second)); + U* entryPointer = std::get_if(std::addressof(it->second)); cachedValue->store(entryPointer); } @@ -228,7 +227,7 @@ template void TF_API Tf_InitializeEnvSetting(TfEnvSetting *); template void TF_API Tf_InitializeEnvSetting(TfEnvSetting *); TF_API -boost::variant const * +std::variant const * Tf_GetEnvSettingByName(std::string const& name) { return Tf_EnvSettingRegistry::GetInstance().LookupByName(name); diff --git a/pxr/base/tf/wrapEnvSetting.cpp b/pxr/base/tf/wrapEnvSetting.cpp index c932f57745..b05b498a69 100644 --- a/pxr/base/tf/wrapEnvSetting.cpp +++ b/pxr/base/tf/wrapEnvSetting.cpp @@ -27,31 +27,31 @@ #include #include -#include #include +#include #include "pxr/base/tf/envSetting.h" PXR_NAMESPACE_OPEN_SCOPE -extern boost::variant const * +extern std::variant const * Tf_GetEnvSettingByName(std::string const&); static boost::python::object _GetEnvSettingByName(std::string const& name) { - boost::variant const * + std::variant const * variantValue = Tf_GetEnvSettingByName(name); if (!variantValue) { return boost::python::object(); } - if (std::string const *value = boost::get(variantValue)) { + if (std::string const *value = std::get_if(variantValue)) { return boost::python::object(*value); - } else if (bool const *value = boost::get(variantValue)) { + } else if (bool const *value = std::get_if(variantValue)) { return boost::python::object(*value); - } else if (int const *value = boost::get(variantValue)) { + } else if (int const *value = std::get_if(variantValue)) { return boost::python::object(*value); }