Template Type Deduction
template<typename T> void f(ParamType param);
f(expr);
Case 1: ParamType
is a Reference or Pointer, but not a Universal Reference
- if
expr
's type is a reference, ignore the refernece part - Then pattern-matched
expr
's type againstParamType
to determineT
.
template <typename T> void f(T& param);
int x = 27;
f(x); // T is int, param's type is int&
int const cx = x;
f(cx); // T is int const, param's type is int const&
int const& rx = x;
f(rx); // T is int const, param's type is int const&
te