1

I'm learning template argument deduction stuff,I have read <14.8.2.1 Deducing template arguments from a function call>(C++11 draft) many times and I think that it missed a rule:
If P is not a reference type: If A is a reference type, the ref-qualifier of A’s type are ignored for type deduction.


It must be my fault, but I dont know where it is.

4

1 回答 1

2

A是函数参数的类型。函数参数是一个表达式,表达式永远没有引用类型。假设你有int i;, int &r = i;。表达式i和表达式r都只有 type int,并且是左值。两者都没有 type int &。在某些情况下,名称不是作为表达式使用(decltype对于特定的句法结构有特殊例外,它们不被视为表达式),在这种情况下,区别很重要,但使用对象作为函数争论不是其中之一。

于 2013-12-25T11:12:46.077 回答