Skip to content

Commit

Permalink
Merge pull request #2708 from nvmkuruc/tracevariant
Browse files Browse the repository at this point in the history
Replace `boost::variant` with `std::variant` in `pxr/base/trace`

(Internal change: 2296111)
  • Loading branch information
pixar-oss committed Sep 19, 2023
2 parents 74433ee + fdc1f54 commit 28af30d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions pxr/base/trace/eventData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ PXR_NAMESPACE_OPEN_SCOPE

namespace {

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

// Boost variant visitor to convert TraceEventData to TraceEvent::DataType
class Type_visitor : public boost::static_visitor<TraceEvent::DataType>
// Variant visitor to convert TraceEventData to 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 28af30d

Please sign in to comment.