diff --git a/ThirdParty/variant/variant.hpp b/ThirdParty/variant/variant.hpp index 3eac9b82c..c3c098923 100644 --- a/ThirdParty/variant/variant.hpp +++ b/ThirdParty/variant/variant.hpp @@ -4,7 +4,6 @@ #include #include #include -#include // std::move/swap #include // runtime_error #include // operator new #include // size_t @@ -515,22 +514,13 @@ public: VARIANT_INLINE variant(no_init) : type_index(detail::invalid_value) {} + // http://isocpp.org/blog/2012/11/universal-references-in-c11-scott-meyers template ::value>::type> - VARIANT_INLINE explicit variant(T const& val) noexcept - : type_index(detail::value_traits::index) - { - constexpr std::size_t index = sizeof...(Types) - detail::value_traits::index - 1; - using target_type = typename detail::select_type::type; - new (&data) target_type(val); - } - - template ::value>::type> + detail::is_valid_type::type, Types...>::value>::type> VARIANT_INLINE variant(T && val) noexcept - : type_index(detail::value_traits::index) + : type_index(detail::value_traits::type, Types...>::index) { - constexpr std::size_t index = sizeof...(Types) - detail::value_traits::index - 1; + constexpr std::size_t index = sizeof...(Types) - detail::value_traits::type, Types...>::index - 1; using target_type = typename detail::select_type::type; new (&data) target_type(std::forward(val)); // nothrow } @@ -721,11 +711,24 @@ auto VARIANT_INLINE static apply_visitor(F f, V & v0, V & v1) -> decltype(V::bin return V::binary_visit(v0, v1, f); } +// getter interface +template +ResultType & get(T & var) +{ + return var.template get(); +} + +template +ResultType const& get(T const& var) +{ + return var.template get(); +} + // operator<< -template +template VARIANT_INLINE std::basic_ostream& -operator<< (std::basic_ostream& out, Variant const& rhs) +operator<< (std::basic_ostream& out, variant const& rhs) { detail::printer> visitor(out); apply_visitor(visitor, rhs);