I don\'t understand why the array decays to a pointer in a template function.
If you look at the following code: When the parameter is forced to be a reference (fun
To quote from spec, it says
(14.8.2.1/2) If P is not a reference type: — If A is an array type, the pointer type produced by the array-to-pointer standard conversion (4.2) is used in place of A for type deduction; otherwise
So, in your case, It is clear that,
template
void f1(T& buff) {
std::cout << "f:buff size:" << sizeof(buff) << std::endl; //prints 3
}
doesn't decay into pointer.