Skip to content

Instantly share code, notes, and snippets.

@Fuyutsubaki
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fuyutsubaki/d51bb730df55c2118936 to your computer and use it in GitHub Desktop.
Save Fuyutsubaki/d51bb730df55c2118936 to your computer and use it in GitHub Desktop.
local_type_hash
#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