diff --git a/include/mapbox/variant.hpp b/include/mapbox/variant.hpp index d7db91a..335a4be 100644 --- a/include/mapbox/variant.hpp +++ b/include/mapbox/variant.hpp @@ -170,9 +170,12 @@ template struct value_traits { using value_type = typename std::remove_const::type>::type; + using value_type_wrapper = recursive_wrapper; static constexpr type_index_t direct_index = direct_type::index; static constexpr bool is_direct = direct_index != invalid_value; - static constexpr type_index_t index = is_direct ? direct_index : convertible_type::index; + static constexpr type_index_t index_direct_or_wrapper = is_direct ? direct_index : direct_type::index; + static constexpr bool is_direct_or_wrapper = index_direct_or_wrapper != invalid_value; + static constexpr type_index_t index = is_direct_or_wrapper ? index_direct_or_wrapper : convertible_type::index; static constexpr bool is_valid = index != invalid_value; static constexpr type_index_t tindex = is_valid ? sizeof...(Types)-index : 0; using target_type = typename std::tuple_element>::type;