Why is typeid(someType) not constant like sizeof(someType) ?
This question came up because recently i tried something like:
template <class T>
class Foo
{
static_assert(typeid(T)==typeid(Bar) || typeid(T)==typeid(FooBar));
};
And i am curious why the compiler knows the size of types (sizeof) at compile time, but not the type itself (typeid)
is_same
is a part of Standard library since C++11, as well asstatic_assert
. – Alanna