[temp.arg] # 13 Templates [[temp]](./#temp) ## 13.4 Template arguments [temp.arg] ### [13.4.1](#general) General [[temp.arg.general]](temp.arg.general) [1](#general-1) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L1009) The type and form of each [*template-argument*](temp.names#nt:template-argument "13.3 Names of template specializations [temp.names]") specified in a [*template-id*](temp.names#nt:template-id "13.3 Names of template specializations [temp.names]") or in a [*splice-specialization-specifier*](basic.splice#nt:splice-specialization-specifier "6.6 Splice specifiers [basic.splice]") shall match the type and form specified for the corresponding parameter declared by the template in its[*template-parameter-list*](temp.pre#nt:template-parameter-list "13.1 Preamble [temp.pre]")[.](#general-1.sentence-1) When the parameter declared by the template is a[template parameter pack](temp.variadic#def:template_parameter_pack "13.7.4 Variadic templates [temp.variadic]"), it will correspond to zero or more[*template-argument*](temp.names#nt:template-argument "13.3 Names of template specializations [temp.names]")*s*[.](#general-1.sentence-2) [*Example [1](#general-example-1)*: template class Array { T* v; int sz;public:explicit Array(int); T& operator[](int); T& elem(int i) { return v[i]; }}; Array v1(20);typedef std::complex dcomplex; // std​::​complex is a standard library template Array v2(30); Array v3(40); void bar() { v1[3] = 7; v2[3] = v3.elem(4) = dcomplex(7,8);} — *end example*] [2](#general-2) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L1043) The template argument list of a [*template-head*](temp.pre#nt:template-head "13.1 Preamble [temp.pre]") is a template argument list in which the nth template argument has the value of the nth template parameter of the [*template-head*](temp.pre#nt:template-head "13.1 Preamble [temp.pre]")[.](#general-2.sentence-1) If the nth template parameter is a template parameter pack ([[temp.variadic]](temp.variadic "13.7.4 Variadic templates")), the nth template argument is a pack expansion whose pattern is the name of the template parameter pack[.](#general-2.sentence-2) [3](#general-3) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L1053) In a[*template-argument*](temp.names#nt:template-argument "13.3 Names of template specializations [temp.names]"), an ambiguity between a[*type-id*](dcl.name#nt:type-id "9.3.2 Type names [dcl.name]") and an expression is resolved to a[*type-id*](dcl.name#nt:type-id "9.3.2 Type names [dcl.name]"), regardless of the form of the corresponding[*template-parameter*](temp.param#nt:template-parameter "13.2 Template parameters [temp.param]")[.](#general-3.sentence-1)[109](#footnote-109 "There is no such ambiguity in a default template-argument because the form of the template-parameter determines the allowable forms of the template-argument.") [*Example [2](#general-example-2)*: template void f();template void f(); void g() { f(); // int() is a type-id: call the first f()} — *end example*] [4](#general-4) [#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L1081) [*Note [1](#general-note-1)*: Names used in a [*template-argument*](temp.names#nt:template-argument "13.3 Names of template specializations [temp.names]") are subject to access control where they appear[.](#general-4.sentence-1) Because a template parameter is not a class member, no access control applies where the template parameter is used[.](#general-4.sentence-2) — *end note*] [*Example [3](#general-example-3)*: template class X {static T t;}; class Y {private:struct S { /* ... */ }; X x; // OK, S is accessible// X has a static member of type Y​::​S// OK, even though Y​::​S is private}; X y; // error: S not accessible — *end example*] For a template argument that is a class type or a class template, the template definition has no special access rights to the members of the template argument[.](#general-4.sentence-3) [*Example [4](#general-example-4)*: template