#include <iostream>
#include <typeinfo>
class A {};
class B {};
class C {};
template<typename T>
std::size_t constexpr getID() { return typeid(T).hash_code(); }
template<std::size_t N>
struct FF
{
};
int main()
{
std::cout << getID<A>() << std::endl;
std::cout << getID<B>() << std::endl;
std::cout << getID<C>() << std::endl;
FF<getID<A>()> a;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHlwZWluZm8+CgpjbGFzcyBBIHt9OwpjbGFzcyBCIHt9OwpjbGFzcyBDIHt9OwoKdGVtcGxhdGU8dHlwZW5hbWUgVD4gCnN0ZDo6c2l6ZV90IGNvbnN0ZXhwciBnZXRJRCgpIHsgcmV0dXJuIHR5cGVpZChUKS5oYXNoX2NvZGUoKTsgfQoKdGVtcGxhdGU8c3RkOjpzaXplX3QgTj4Kc3RydWN0IEZGCnsKCQp9OwoKaW50IG1haW4oKQp7CiAgICBzdGQ6OmNvdXQgPDwgZ2V0SUQ8QT4oKSA8PCBzdGQ6OmVuZGw7CiAgICBzdGQ6OmNvdXQgPDwgZ2V0SUQ8Qj4oKSA8PCBzdGQ6OmVuZGw7CiAgICBzdGQ6OmNvdXQgPDwgZ2V0SUQ8Qz4oKSA8PCBzdGQ6OmVuZGw7CgoJRkY8Z2V0SUQ8QT4oKT4gYTsKCiAgICByZXR1cm4gMDsKfQ==
prog.cpp: In function ‘int main()’:
prog.cpp:23:14: error: ‘constexpr std::size_t getID() [with T = A; std::size_t = unsigned int]’ called in a constant expression
FF<getID<A>()> a;
^
prog.cpp:9:23: note: ‘constexpr std::size_t getID() [with T = A; std::size_t = unsigned int]’ is not usable as a constexpr function because:
std::size_t constexpr getID() { return typeid(T).hash_code(); }
^
prog.cpp:9:60: error: call to non-constexpr function ‘std::size_t std::type_info::hash_code() const’
std::size_t constexpr getID() { return typeid(T).hash_code(); }
^
prog.cpp:23:15: note: in template argument for type ‘unsigned int’
FF<getID<A>()> a;
^
prog.cpp:23:18: error: invalid type in declaration before ‘;’ token
FF<getID<A>()> a;
^
prog.cpp:23:17: warning: unused variable ‘a’ [-Wunused-variable]
FF<getID<A>()> a;
^