【发布时间】:2021-08-06 13:21:02
【问题描述】:
在这种情况下,您有什么建议避免使用类型别名?
// this is a header file, sample.h
#ifdef _WIN32
using default_type = int;
#else
using default_type = float;
#endif
template<typename T = default_type>
class Sample
{
};
我不想在这里使用类型别名,因为我不想在我的头文件中使用类型别名。
【问题讨论】:
-
不想要别名的原因是什么?如果是名称冲突,命名空间可能是比解决方法更合适的解决方案。