From 9dcea2083f85be65e617108c4fdb116d0572e1a9 Mon Sep 17 00:00:00 2001 From: Adam Casey Date: Wed, 30 Jun 2021 16:57:31 +0100 Subject: [PATCH] FieldValue: Switch to std::variant Since moving to C++17 we can replace boost::variant with std::variant. Confirmed amqpprox runs OK and the unit tests log a method containing a FieldTable. --- libamqpprox/amqpprox_fieldvalue.cpp | 7 ++++--- libamqpprox/amqpprox_fieldvalue.h | 23 +++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libamqpprox/amqpprox_fieldvalue.cpp b/libamqpprox/amqpprox_fieldvalue.cpp index 0710318..2f6cb65 100644 --- a/libamqpprox/amqpprox_fieldvalue.cpp +++ b/libamqpprox/amqpprox_fieldvalue.cpp @@ -18,6 +18,7 @@ #include #include +#include namespace Bloomberg { namespace amqpprox { @@ -68,15 +69,15 @@ std::ostream &operator<<(std::ostream &os, const FieldValue &value) { switch (value.d_type) { case 'F': - os << *boost::get>(value.d_value); + os << *std::get>(value.d_value); break; case 'S': os << "\""; - boost::apply_visitor(FieldValuePrinter(os), value.d_value); + std::visit(FieldValuePrinter(os), value.d_value); os << "\""; break; default: - boost::apply_visitor(FieldValuePrinter(os), value.d_value); + std::visit(FieldValuePrinter(os), value.d_value); break; } return os; diff --git a/libamqpprox/amqpprox_fieldvalue.h b/libamqpprox/amqpprox_fieldvalue.h index 848f44f..c59f791 100644 --- a/libamqpprox/amqpprox_fieldvalue.h +++ b/libamqpprox/amqpprox_fieldvalue.h @@ -16,10 +16,9 @@ #ifndef BLOOMBERG_AMQPPROX_FIELDVALUE #define BLOOMBERG_AMQPPROX_FIELDVALUE -#include - #include #include +#include #include namespace Bloomberg { @@ -32,13 +31,13 @@ class FieldTable; * https://www.rabbitmq.com/amqp-0-9-1-errata.html */ class FieldValue { - boost::variant, - std::vector, - std::shared_ptr> + std::variant, + std::vector, + std::shared_ptr> d_value; char d_type; @@ -134,13 +133,13 @@ inline char FieldValue::type() const template T FieldValue::value() { - return boost::get(d_value); + return std::get(d_value); } template T FieldValue::value() const { - return boost::get(d_value); + return std::get(d_value); } std::ostream &operator<<(std::ostream &os, const FieldValue &value); @@ -155,7 +154,7 @@ inline bool operator!=(const FieldValue &lhs, const FieldValue &rhs) return !(lhs == rhs); } -class FieldValuePrinter : public boost::static_visitor { +class FieldValuePrinter { std::ostream &d_printStream; public: