Skip to content

Commit

Permalink
add static which<T>() function to get a contained types' which value
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer committed Jun 1, 2016
1 parent 2f8a4a3 commit 74ce146
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/mapbox/variant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,13 @@ class variant
return static_cast<int>(sizeof...(Types)-type_index - 1);
}

template <typename T, typename std::enable_if<
(detail::direct_type<T, Types...>::index != detail::invalid_value)>::type* = nullptr>
VARIANT_INLINE static constexpr int which() noexcept
{
return static_cast<int>(sizeof...(Types)-detail::direct_type<T, Types...>::index - 1);
}

// visitor
// unary
template <typename F, typename V, typename R = typename detail::result_of_unary_visit<F, first_type>::type>
Expand Down

0 comments on commit 74ce146

Please sign in to comment.