16.1.3. Template Parameters

Image

Like the names of function parameters, a template parameter name has no intrinsic meaning. We ordinarily name type parameters T, but we can use any name:

template <typename Foo> Foo calc(const Foo& a, const Foo& b){    Foo tmp = a; // tmp has the same type as the parameters and return type    // ...    return tmp;  // return type and parameters have the same type}

Template Parameters and Scope

Template parameters follow normal scoping rules. The name of a template parameter can be used after it has been declared and until the end of the template declaration or definition. As with any other name, a template parameter ...

Get C++ Primer, Fifth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.