c++ - 模板参数中的 "T"和 "const T"有区别吗?

标签 c++ templates syntax constants

下面两种语法有区别吗:

template<int N> struct A;         // (1)

template<const int N> struct A;   // (2)

关于何时使用每种语法的任何一般准则?

最佳答案

没有。

§14.1 [temp.param] p5

[...] The top-level cv-qualifiers on the template-parameter are ignored when determining its type.

关于c++ - 模板参数中的 "T"和 "const T"有区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65775669/

相关文章:

c++ - 从 QSqlTableModel::record() 返回的 QSqlRecord 为空

c++ - 嵌套或继承的类型特征

C++模板类原型(prototype)、函数定义

python - 忽略查找和替换算法中引号中的字符

c++ - 为什么在我执行 copy-and-swap 惯用语时不调用我的复制构造函数?

c++ - 在 do-while 循环中同时检查两个条件

c++ - 找到四分位数

c++ - 根据 is_integer 转换为 int 或 float

c# - "DateTime?"在 C# 中是什么意思?

mysql - SQL USE INDEX 语法错误