Skip to content

Instantly share code, notes, and snippets.

@djarek
Created September 29, 2016 22:37
Show Gist options
  • Save djarek/56457645f8c0ce7fc00f436fc0f82cb3 to your computer and use it in GitHub Desktop.
Save djarek/56457645f8c0ce7fc00f436fc0f82cb3 to your computer and use it in GitHub Desktop.
template <typename T, typename U=void, typename... Types>
constexpr size_t index() {
return std::is_same<T, U>::value ? 0 : 1 + index<T, Types...>();
}
template<size_t index, typename... T>
struct TypeAtIndex
{
using type = typename std::tuple_element<index, std::tuple<T...>>::type;
};
template <typename... T>
struct TestPackIndex {
static constexpr auto value = index<bool ,T...>();
using type = typename TypeAtIndex<value, T...>::type;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment