模板类型推断时,常引用的constness要不要保留

C++语言 码拜 7年前 (2017-04-16) 923次浏览
Effective Modern C++的Item 1, Case3:ParamType is Neigher a Pointer nor a Reference(影印版p14底)里面写到

引用:
Quote: 引用:

As we”ve seen, for parameters that are references-to or pointers-to-const, the constness of expr is preserved during type deduction.
这里的parameters 对于
template<typename T>
void tFunc (T param)
{

}
来说 是指param是references-to or pointers-to-const

恩,但是param是references-to的时候,没有保留constness啊

去看下前面的case 1你就知道了


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明模板类型推断时,常引用的constness要不要保留
喜欢 (0)
[1034331897@qq.com]
分享 (0)