mapbox/variant: Align API with std::variant
Tested:
Builds and unit tests still pass. Manually tested that
has_alternative works as expected.
Change-Id: Iae8309c09a6aac6b9b12164d5fe7ae4e484cb905
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/mapbox/variant.hpp b/mapbox/variant.hpp
index 14fe75c..9f039bc 100644
--- a/mapbox/variant.hpp
+++ b/mapbox/variant.hpp
@@ -1079,6 +1079,16 @@
return V::binary_visit(v0, v1, std::forward<F>(f));
}
+// is interface
+
+#ifdef HAS_EXCEPTIONS
+template <typename ResultType, typename T>
+auto holds_alternative(T const& var) -> decltype(var.template is<ResultType>())
+{
+ return var.template is<ResultType>();
+}
+#endif
+
// getter interface
#ifdef HAS_EXCEPTIONS