相关疑难解决方法(0)

C++标准中14.8.2第3和第4段的含义是什么?

我正在努力理解这个规则,特别是下面的粗体句子(我的重点):

考虑注释#2在下面的代码片段:这是什么意思是说,功能类型f(int),但是tconst

§14.8.2/3:

执行此替换后,将执行8.3.5中描述的功能参数类型调整.[示例:参数类型" void ()(const int, int[5])"变为" void(*)(int,int*)".-end example] [注意:函数参数声明中的顶级限定符不会影响函数类型,但仍会影响函数中函数参数变量的类型.- 尾注 ] [示例:

template <class T> void f(T t);
template <class X> void g(const X x);
template <class Z> void h(Z, Z*);
int main() {
    // #1: function type is f(int), t is non const
    f<int>(1);
    // #2: function type is f(int), t is const
    f<const int>(1);
    // #3: function type is g(int), x is const
    g<int>(1);
    // #4: …
Run Code Online (Sandbox Code Playgroud)

c++ templates c++11

7
推荐指数
2
解决办法
296
查看次数

标签 统计

c++ ×1

c++11 ×1

templates ×1