nicoulaj
nicoulaj

Reputation: 3543

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>.

Upvotes: 3

Views: 462

Answers (1)

Yakk - Adam Nevraumont
Yakk - Adam Nevraumont

Reputation: 275385

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.

Upvotes: 3

Related Questions