Last active
September 9, 2021 19:53
-
-
Save picanumber/7703b3c70b1c3d4045300ffcc30be9ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <class T, class Tuple, std::size_t I = 0> | |
consteval std::size_t TypeIndex() { | |
if constexpr (I >= std::tuple_size<Tuple>::value) { | |
return 0; | |
} else if constexpr (std::is_same_v<T, std::tuple_element_t<I, Tuple>>) { | |
return I + 1; | |
} else { | |
return TypeIndex<T, Tuple, I + 1>(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment