132 lines
6.4 KiB
Markdown
132 lines
6.4 KiB
Markdown
[temp.point]
|
||
|
||
# 13 Templates [[temp]](./#temp)
|
||
|
||
## 13.8 Name resolution [[temp.res]](temp.res#temp.point)
|
||
|
||
### 13.8.4 Dependent name resolution [[temp.dep.res]](temp.dep.res#temp.point)
|
||
|
||
#### 13.8.4.1 Point of instantiation [temp.point]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L6073)
|
||
|
||
For a function template specialization, a member function template
|
||
specialization, or a specialization for a member function or static data member
|
||
of a class template,
|
||
if the specialization is implicitly instantiated because it is referenced
|
||
from within another template specialization and
|
||
the context from which it is referenced depends on a template parameter,
|
||
the point of instantiation of the specialization is the point of instantiation
|
||
of the enclosing specialization[.](#1.sentence-1)
|
||
|
||
Otherwise, the point of instantiation for such a specialization immediately
|
||
follows the namespace scope declaration
|
||
or definition that refers to the specialization[.](#1.sentence-2)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L6087)
|
||
|
||
If a function template or member function of a class template is called
|
||
in a way which uses the definition of a default argument of that function
|
||
template or member function,
|
||
the point of instantiation of the default argument is the point of
|
||
instantiation of the function template or member function specialization[.](#2.sentence-1)
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L6094)
|
||
|
||
For a [*noexcept-specifier*](except.spec#nt:noexcept-specifier "14.5 Exception specifications [except.spec]") of a function template
|
||
specialization or specialization of a member function of a class template, if
|
||
the [*noexcept-specifier*](except.spec#nt:noexcept-specifier "14.5 Exception specifications [except.spec]") is implicitly instantiated because
|
||
it is needed by another template specialization and the context that requires
|
||
it depends on a template parameter, the point of instantiation of the[*noexcept-specifier*](except.spec#nt:noexcept-specifier "14.5 Exception specifications [except.spec]") is the point of instantiation of the
|
||
specialization that requires it[.](#3.sentence-1)
|
||
|
||
Otherwise, the point of instantiation for such
|
||
a [*noexcept-specifier*](except.spec#nt:noexcept-specifier "14.5 Exception specifications [except.spec]") immediately follows the namespace
|
||
scope declaration or definition that requires the[*noexcept-specifier*](except.spec#nt:noexcept-specifier "14.5 Exception specifications [except.spec]")[.](#3.sentence-2)
|
||
|
||
[4](#4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L6106)
|
||
|
||
For a class template specialization, a class member template specialization,
|
||
or a specialization for a class member of a class template,
|
||
if the specialization is implicitly instantiated because it is referenced
|
||
from within another template specialization,
|
||
if the context from which the specialization is referenced depends on a
|
||
template parameter,
|
||
and if the specialization is not instantiated previous to the instantiation of
|
||
the enclosing template,
|
||
the point of instantiation is immediately before the point of instantiation of
|
||
the enclosing template[.](#4.sentence-1)
|
||
|
||
Otherwise, the point of instantiation for such a specialization immediately
|
||
precedes the namespace scope declaration
|
||
or definition that refers to the specialization[.](#4.sentence-2)
|
||
|
||
[5](#5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L6121)
|
||
|
||
If a virtual function is implicitly instantiated, its point of instantiation
|
||
is immediately following the point of instantiation of its enclosing class
|
||
template specialization[.](#5.sentence-1)
|
||
|
||
[6](#6)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L6126)
|
||
|
||
An explicit instantiation definition is an instantiation
|
||
point for the specialization or specializations specified by the explicit
|
||
instantiation[.](#6.sentence-1)
|
||
|
||
[7](#7)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L6131)
|
||
|
||
A specialization for a function template, a member function template,
|
||
or of a member function or static data member of a class template may have
|
||
multiple points of instantiations within a translation unit, and in addition
|
||
to the points of instantiation described above,
|
||
|
||
- [(7.1)](#7.1)
|
||
|
||
for any such
|
||
specialization that has a point of instantiation within the[*declaration-seq*](dcl.pre#nt:declaration-seq "9.1 Preamble [dcl.pre]") of the[*translation-unit*](basic.link#nt:translation-unit "6.7 Program and linkage [basic.link]"),
|
||
prior to the [*private-module-fragment*](module.private.frag#nt:private-module-fragment "10.5 Private module fragment [module.private.frag]") (if any),
|
||
the point after the [*declaration-seq*](dcl.pre#nt:declaration-seq "9.1 Preamble [dcl.pre]") of the [*translation-unit*](basic.link#nt:translation-unit "6.7 Program and linkage [basic.link]") is also considered a point of instantiation,
|
||
and
|
||
|
||
- [(7.2)](#7.2)
|
||
|
||
for any such specialization that has a point of instantiation
|
||
within the [*private-module-fragment*](module.private.frag#nt:private-module-fragment "10.5 Private module fragment [module.private.frag]"),
|
||
the end of the translation unit is also
|
||
considered a point of instantiation[.](#7.sentence-1)
|
||
|
||
A specialization for a class template has at most one point of instantiation
|
||
within a translation unit[.](#7.sentence-2)
|
||
|
||
A specialization for any template may have points of instantiation in multiple
|
||
translation units[.](#7.sentence-3)
|
||
|
||
If two different points of instantiation give a template specialization
|
||
different meanings according to the [one-definition rule](basic.def.odr "6.3 One-definition rule [basic.def.odr]"),
|
||
the program is ill-formed, no diagnostic required[.](#7.sentence-4)
|
||
|
||
[8](#8)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/templates.tex#L6161)
|
||
|
||
For the [*compound-statement*](stmt.block#nt:compound-statement "8.4 Compound statement or block [stmt.block]") of an expansion statement ([[stmt.expand]](stmt.expand "8.7 Expansion statements")),
|
||
the point of instantiation is the point of instantiation
|
||
of its enclosing templated entity, if any[.](#8.sentence-1)
|
||
|
||
Otherwise, it immediately follows the namespace-scope declaration
|
||
or definition that contains the expansion statement[.](#8.sentence-2)
|