If I have a tuple with different element types like
std::tuple
And how to get the index of a element type?
template
struct Index;
template
struct Index> {
static const std::size_t value = 0;
};
template
struct Index> {
static const std::size_t value = 1 + Index>::value;
};
See it live at Coliru.
This implementation returns the index of the first occurrence of a given type. Asking for the index of a type that is not in the tuple results in a compile error (and a fairly ugly one at that).