Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

varint index

template <typename> struct tag { };

template <typename T, typename V>
struct variant_index;

template <typename T, typename... Ts> 
struct variant_index<T, std::variant<Ts...>>
    : std::integral_constant<size_t, std::variant<tag<Ts>...>(tag<T>()).index()>
{ };

// Use as: variant_index<TYPE, VARIANT>::value
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #varint #index
ADD COMMENT
Topic
Name
9+2 =