Fix std::variant usage
This change makes it possible to use std::variant as a drop in
replacement for mapbox::variant.
Change-Id: Ia729c3a7832eec4dd6cddadba9bc160b6ba9ad90
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/functor.hpp b/functor.hpp
index ff60c7d..d00ec48 100644
--- a/functor.hpp
+++ b/functor.hpp
@@ -227,7 +227,8 @@
return false;
}
- return _condition(std::forward<T>(it->second.template get<T>()));
+ return _condition(std::forward<T>(
+ sdbusplus::message::variant_ns::get<T>(it->second)));
}
private:
@@ -353,7 +354,8 @@
{
sdbusplus::message::variant<T> value;
msg.read(value);
- return _condition(std::forward<T>(value.template get<T>()));
+ return _condition(
+ std::forward<T>(sdbusplus::message::variant_ns::get<T>(value)));
}
/** @brief Retrieve a property value from inventory and test it.
diff --git a/test/test.cpp b/test/test.cpp
index 2327239..cf61b84 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -425,7 +425,8 @@
sig.read(sigInterface);
assert(sigInterface == "xyz.openbmc_project.Example.Iface1");
sig.read(sigProperties);
- assert(sigProperties["ExampleProperty1"] == "changed");
+ assert(sdbusplus::message::variant_ns::get<std::string>(
+ sigProperties["ExampleProperty1"]) == "changed");
}
}
}
diff --git a/utils.hpp b/utils.hpp
index aacee5e..2fd0805 100644
--- a/utils.hpp
+++ b/utils.hpp
@@ -26,8 +26,8 @@
{
static auto make(Arg&& arg)
{
- throw sdbusplus::message::variant_ns::bad_variant_access(
- "in MakeVariantVisitor");
+ throw std::runtime_error(
+ "Invalid conversion in MakeVariantVisitor");
return T();
}
};
@@ -67,8 +67,7 @@
template <typename V, typename Arg>
auto convertVariant(Arg&& v)
{
- return sdbusplus::message::variant_ns::apply_visitor(
- MakeVariantVisitor<V>(), v);
+ return sdbusplus::message::variant_ns::visit(MakeVariantVisitor<V>(), v);
}
/** @struct CompareFirst