Search code examples
c++templatesstltypedeftype-traits

Does GCC STL have a trait that gets the primitive type from typedef aliases?


I can't find a metafunction which returns the primitive type from its typedef aliases, like in that possible example:

typedef int ivar;
typedef ivar signIvar;

...
// true
std::cout << std::is_same< int, std::get_primitive<signIvar>::type >::value;

It may exist, but I cannot find it. Implementation is possible in principle, but I can only make it expensive for compile time.


Solution

  • There is conceptually no such thing as "get primitive type from its typedef alias".

    An alias of a type is simply a name for the same type. As such, you can do:

    std::cout << std::is_same_v<int, signIvar>; // output: 1