是否有可能在C ++中获取类型别名的名称?

时间:2018-01-13 17:01:03

标签: c++ templates metaprogramming template-meta-programming

在C ++中,是否可以获取类型别名的名称?

例如:

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

会打印my_type,而不是some_type<a,b,c>

1 个答案:

答案 0 :(得分:3)

不,你不能,禁止使用字符串化宏(与类型系统无关)。

有很多方法可以执行强类型定义,但它们会生成新类型。

请注意,typeid上的名称不需要是人类可读的,甚至是唯一的。

相关问题