如果我创建一个诸如typedef的类型定义,例如:
typedef int const cint;
cint
将引用一个不可修改的 int。我可以在任何需要类型的上下文中使用 cint
(模板参数、函数定义等)。
然而,typedef 不能与模板一起使用。我的希望是能够像上面使用 cint
一样声明一个模板,例如 Constant<SomeType>
,并将其引用为 const SomeType
。这种方式是否可行?
template <typename T> using Constant = const T;
- Piotr Skotnicki