Last active
August 29, 2015 14:07
-
-
Save Fuyutsubaki/d51bb730df55c2118936 to your computer and use it in GitHub Desktop.
local_type_hash
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
#include<iostream> | |
#include<type_traits> | |
template<class> | |
struct wrap{}; | |
template<std::size_t N, class T, class ...R> | |
struct A | |
:A<N + 1, R...> | |
{ | |
using A<N + 1, R...>::operator(); | |
std::integral_constant<std::size_t, N> operator()(wrap<T>); | |
}; | |
template<std::size_t N, class T> | |
struct A<N, T> | |
{ | |
std::integral_constant<std::size_t, N> operator()(wrap<T>); | |
}; | |
template<class L, class...R> | |
struct Y :L | |
{ | |
using L::operator(); | |
template<class T> | |
decltype(Y<R...>{}(T{})) operator()(T); | |
}; | |
template<class L> | |
struct Y<L> :L | |
{}; | |
int main() | |
{ | |
Y<A<0, char, int, long>, A<3, char, int*, int*>, A<6, char, int*, long>> c; | |
using C = decltype(c.operator()(wrap<int*>{})); | |
std::cout << C::value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment