Skip to content

Commit

Permalink
Replace boost::variant with std::variant in pxr/base/trace
Browse files Browse the repository at this point in the history
  • Loading branch information
nvmkuruc committed Sep 18, 2023
1 parent 6988a51 commit dd3b149
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions pxr/base/trace/eventData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ PXR_NAMESPACE_OPEN_SCOPE
namespace {

// Boost variant visitor to convert TraceEventData to JsValue
class JsValue_visitor : public boost::static_visitor<void>
class JsValue_visitor
{
public:
JsValue_visitor(JsWriter& writer)
Expand Down Expand Up @@ -68,7 +68,7 @@ class JsValue_visitor : public boost::static_visitor<void>
};

// Boost variant visitor to convert TraceEventData to TraceEvent::DataType
class Type_visitor : public boost::static_visitor<TraceEvent::DataType>
class Type_visitor
{
public:
TraceEvent::DataType operator()(int64_t i) const {
Expand Down Expand Up @@ -101,42 +101,42 @@ class Type_visitor : public boost::static_visitor<TraceEvent::DataType>

TraceEvent::DataType TraceEventData::GetType() const
{
return boost::apply_visitor(Type_visitor(), _data);
return std::visit(Type_visitor(), _data);
}

const int64_t* TraceEventData::GetInt() const
{
return GetType() == TraceEvent::DataType::Int ?
&boost::get<int64_t>(_data) : nullptr;
&std::get<int64_t>(_data) : nullptr;
}

const uint64_t* TraceEventData::GetUInt() const
{
return GetType() == TraceEvent::DataType::UInt ?
&boost::get<uint64_t>(_data) : nullptr;
&std::get<uint64_t>(_data) : nullptr;
}

const double* TraceEventData::GetFloat() const
{
return GetType() == TraceEvent::DataType::Float ?
&boost::get<double>(_data) : nullptr;
&std::get<double>(_data) : nullptr;
}

const bool* TraceEventData::GetBool() const
{
return GetType() == TraceEvent::DataType::Boolean ?
&boost::get<bool>(_data) : nullptr;
&std::get<bool>(_data) : nullptr;
}

const std::string* TraceEventData::GetString() const
{
return GetType() == TraceEvent::DataType::String ?
&boost::get<std::string>(_data) : nullptr;
&std::get<std::string>(_data) : nullptr;
}

void TraceEventData::WriteJson(JsWriter& writer) const
{
boost::apply_visitor(JsValue_visitor(writer), _data);
std::visit(JsValue_visitor(writer), _data);
}

PXR_NAMESPACE_CLOSE_SCOPE
4 changes: 2 additions & 2 deletions pxr/base/trace/eventData.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include "pxr/base/trace/api.h"
#include "pxr/base/trace/event.h"

#include <boost/variant.hpp>
#include <string>
#include <variant>

PXR_NAMESPACE_OPEN_SCOPE

Expand Down Expand Up @@ -88,7 +88,7 @@ class TraceEventData {
struct _NoData {};

using Variant =
boost::variant<_NoData, std::string, bool, int64_t, uint64_t, double>;
std::variant<_NoData, std::string, bool, int64_t, uint64_t, double>;
Variant _data;
};

Expand Down

0 comments on commit dd3b149

Please sign in to comment.