簡體   English   中英

是否有可能在C ++中獲取類型別名的名稱?

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

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

不,你不能,禁止使用字符串化宏(與類型系統無關)。

有很多方法可以執行強類型定義,但它們會生成新類型。

請注意,typeid上的名稱不必是人類可讀的,甚至是唯一的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM