Is it possible to get the name of a type alias in C++?

In C++, is it possible to get the name of a type alias ?

For instance:

using my_type = some_type<a,b,c>;
std::cout << get_type_name<my_type>() << std::endl;

Would print my_type, not some_type<a,b,c>.

1 answer

  • answered 2018-01-13 17:14 Yakk

    No, you cannot, barring stringifying macros (which has nothing to do with type system).

    There are ways to do strong typedefs, but they generate new types.

    Note that the name on a typeid need not be human readable or even unique.