mapbox/variant: Add std::visit compatible function
mapbox used to require that we use the apply_visitor interface. The new
std::variant std::visit() interface is more generic and a superset of the
functionality provided by apply_visitor. We just need to provide an
alias.
Tested:
Used this in phosphor-host-ipmid with a work in progress commit to
make sure the compat layer is working fully.
Change-Id: I6ca9747e4f0825220e47bb9b2965a249466b3593
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/mapbox/variant.hpp b/mapbox/variant.hpp
index 9f039bc..7c02032 100644
--- a/mapbox/variant.hpp
+++ b/mapbox/variant.hpp
@@ -1079,6 +1079,14 @@
return V::binary_visit(v0, v1, std::forward<F>(f));
}
+// Needed for compatibility with std::variant
+template <typename... Args>
+constexpr auto visit(Args&&... args)
+ -> decltype(apply_visitor(std::forward<Args>(args)...))
+{
+ return apply_visitor(std::forward<Args>(args)...);
+}
+
// is interface
#ifdef HAS_EXCEPTIONS