tmp/tmpkwoxny13/{from.md → to.md}
RENAMED
|
@@ -5,18 +5,19 @@ instantiated ([[temp.explicit]]) or explicitly specialized (
|
|
| 5 |
[[temp.expl.spec]]), the class template specialization is implicitly
|
| 6 |
instantiated when the specialization is referenced in a context that
|
| 7 |
requires a completely-defined object type or when the completeness of
|
| 8 |
the class type affects the semantics of the program. The implicit
|
| 9 |
instantiation of a class template specialization causes the implicit
|
| 10 |
-
instantiation of the declarations, but not of the definitions
|
| 11 |
-
arguments, of the class member functions,
|
| 12 |
-
enumerations, static data members and
|
| 13 |
-
|
| 14 |
-
enumerations and member anonymous unions.
|
| 15 |
-
|
| 16 |
-
according to [[class.mem]], a
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
``` cpp
|
| 20 |
template<class T, class U>
|
| 21 |
struct Outer {
|
| 22 |
template<class X, class Y> struct Inner;
|
|
@@ -71,10 +72,17 @@ void h() {
|
|
| 71 |
```
|
| 72 |
|
| 73 |
Nothing in this example requires `class` `Z<double>`, `Z<int>::g()`, or
|
| 74 |
`Z<char>::f()` to be implicitly instantiated.
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
A class template specialization is implicitly instantiated if the class
|
| 77 |
type is used in a context that requires a completely-defined object type
|
| 78 |
or if the completeness of the class type might affect the semantics of
|
| 79 |
the program. In particular, if the semantics of an expression depend on
|
| 80 |
the member or base class lists of a class template specialization, the
|
|
@@ -134,28 +142,28 @@ data members of that class to be implicitly instantiated.
|
|
| 134 |
If a function template or a member function template specialization is
|
| 135 |
used in a way that involves overload resolution, a declaration of the
|
| 136 |
specialization is implicitly instantiated ([[temp.over]]).
|
| 137 |
|
| 138 |
An implementation shall not implicitly instantiate a function template,
|
| 139 |
-
a member template, a non-virtual member function, a
|
| 140 |
-
static data member of a class template that does not
|
| 141 |
-
instantiation. It is unspecified whether or not an
|
| 142 |
-
implicitly instantiates a virtual member function of a
|
| 143 |
-
the virtual member function would not otherwise be
|
| 144 |
-
of a template specialization in a default argument
|
| 145 |
-
template to be implicitly instantiated except that a
|
| 146 |
-
be instantiated where its complete type is needed to
|
| 147 |
-
correctness of the default argument. The use of a default
|
| 148 |
-
function call causes specializations in the default
|
| 149 |
-
implicitly instantiated.
|
| 150 |
|
| 151 |
-
Implicitly instantiated class
|
| 152 |
-
placed in the namespace where the template is
|
| 153 |
-
instantiated specializations for members of a class
|
| 154 |
-
in the namespace where the enclosing class template
|
| 155 |
-
Implicitly instantiated member templates are placed in the
|
| 156 |
-
where the enclosing class or class template is defined.
|
| 157 |
|
| 158 |
``` cpp
|
| 159 |
namespace N {
|
| 160 |
template<class T> class List {
|
| 161 |
public:
|
|
@@ -182,13 +190,16 @@ If a function template `f` is called in a way that requires a default
|
|
| 182 |
argument to be used, the dependent names are looked up, the semantics
|
| 183 |
constraints are checked, and the instantiation of any template used in
|
| 184 |
the default argument is done as if the default argument had been an
|
| 185 |
initializer used in a function template specialization with the same
|
| 186 |
scope, the same template parameters and the same access as that of the
|
| 187 |
-
function template `f` used at that point
|
| 188 |
-
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
Each default argument is instantiated independently.
|
| 192 |
|
| 193 |
``` cpp
|
| 194 |
template<class T> void f(T x, T y = ydef(T()), T z = zdef(T()));
|
|
@@ -202,10 +213,19 @@ void g(A a, A b, A c) {
|
|
| 202 |
f(a, b); // default argument z = zdef(T()) instantiated
|
| 203 |
f(a); // ill-formed; ydef is not declared
|
| 204 |
}
|
| 205 |
```
|
| 206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
[[temp.point]] defines the point of instantiation of a template
|
| 208 |
specialization.
|
| 209 |
|
| 210 |
There is an implementation-defined quantity that specifies the limit on
|
| 211 |
the total depth of recursive instantiations, which could involve more
|
|
|
|
| 5 |
[[temp.expl.spec]]), the class template specialization is implicitly
|
| 6 |
instantiated when the specialization is referenced in a context that
|
| 7 |
requires a completely-defined object type or when the completeness of
|
| 8 |
the class type affects the semantics of the program. The implicit
|
| 9 |
instantiation of a class template specialization causes the implicit
|
| 10 |
+
instantiation of the declarations, but not of the definitions, default
|
| 11 |
+
arguments, or *exception-specification*s of the class member functions,
|
| 12 |
+
member classes, scoped member enumerations, static data members and
|
| 13 |
+
member templates; and it causes the implicit instantiation of the
|
| 14 |
+
definitions of unscoped member enumerations and member anonymous unions.
|
| 15 |
+
However, for the purpose of determining whether an instantiated
|
| 16 |
+
redeclaration of a member is valid according to [[class.mem]], a
|
| 17 |
+
declaration that corresponds to a definition in the template is
|
| 18 |
+
considered to be a definition.
|
| 19 |
|
| 20 |
``` cpp
|
| 21 |
template<class T, class U>
|
| 22 |
struct Outer {
|
| 23 |
template<class X, class Y> struct Inner;
|
|
|
|
| 72 |
```
|
| 73 |
|
| 74 |
Nothing in this example requires `class` `Z<double>`, `Z<int>::g()`, or
|
| 75 |
`Z<char>::f()` to be implicitly instantiated.
|
| 76 |
|
| 77 |
+
Unless a variable template specialization has been explicitly
|
| 78 |
+
instantiated or explicitly specialized, the variable template
|
| 79 |
+
specialization is implicitly instantiated when the specialization is
|
| 80 |
+
used. A default template argument for a variable template is implicitly
|
| 81 |
+
instantiated when the variable template is referenced in a context that
|
| 82 |
+
requires the value of the default argument.
|
| 83 |
+
|
| 84 |
A class template specialization is implicitly instantiated if the class
|
| 85 |
type is used in a context that requires a completely-defined object type
|
| 86 |
or if the completeness of the class type might affect the semantics of
|
| 87 |
the program. In particular, if the semantics of an expression depend on
|
| 88 |
the member or base class lists of a class template specialization, the
|
|
|
|
| 142 |
If a function template or a member function template specialization is
|
| 143 |
used in a way that involves overload resolution, a declaration of the
|
| 144 |
specialization is implicitly instantiated ([[temp.over]]).
|
| 145 |
|
| 146 |
An implementation shall not implicitly instantiate a function template,
|
| 147 |
+
a variable template, a member template, a non-virtual member function, a
|
| 148 |
+
member class, or a static data member of a class template that does not
|
| 149 |
+
require instantiation. It is unspecified whether or not an
|
| 150 |
+
implementation implicitly instantiates a virtual member function of a
|
| 151 |
+
class template if the virtual member function would not otherwise be
|
| 152 |
+
instantiated. The use of a template specialization in a default argument
|
| 153 |
+
shall not cause the template to be implicitly instantiated except that a
|
| 154 |
+
class template may be instantiated where its complete type is needed to
|
| 155 |
+
determine the correctness of the default argument. The use of a default
|
| 156 |
+
argument in a function call causes specializations in the default
|
| 157 |
+
argument to be implicitly instantiated.
|
| 158 |
|
| 159 |
+
Implicitly instantiated class, function, and variable template
|
| 160 |
+
specializations are placed in the namespace where the template is
|
| 161 |
+
defined. Implicitly instantiated specializations for members of a class
|
| 162 |
+
template are placed in the namespace where the enclosing class template
|
| 163 |
+
is defined. Implicitly instantiated member templates are placed in the
|
| 164 |
+
namespace where the enclosing class or class template is defined.
|
| 165 |
|
| 166 |
``` cpp
|
| 167 |
namespace N {
|
| 168 |
template<class T> class List {
|
| 169 |
public:
|
|
|
|
| 190 |
argument to be used, the dependent names are looked up, the semantics
|
| 191 |
constraints are checked, and the instantiation of any template used in
|
| 192 |
the default argument is done as if the default argument had been an
|
| 193 |
initializer used in a function template specialization with the same
|
| 194 |
scope, the same template parameters and the same access as that of the
|
| 195 |
+
function template `f` used at that point, except that the scope in which
|
| 196 |
+
a closure type is declared ([[expr.prim.lambda]]) – and therefore its
|
| 197 |
+
associated namespaces – remain as determined from the context of the
|
| 198 |
+
definition for the default argument. This analysis is called *default
|
| 199 |
+
argument instantiation*. The instantiated default argument is then used
|
| 200 |
+
as the argument of `f`.
|
| 201 |
|
| 202 |
Each default argument is instantiated independently.
|
| 203 |
|
| 204 |
``` cpp
|
| 205 |
template<class T> void f(T x, T y = ydef(T()), T z = zdef(T()));
|
|
|
|
| 213 |
f(a, b); // default argument z = zdef(T()) instantiated
|
| 214 |
f(a); // ill-formed; ydef is not declared
|
| 215 |
}
|
| 216 |
```
|
| 217 |
|
| 218 |
+
The *exception-specification* of a function template specialization is
|
| 219 |
+
not instantiated along with the function declaration; it is instantiated
|
| 220 |
+
when needed ([[except.spec]]). If such an *exception-specification* is
|
| 221 |
+
needed but has not yet been instantiated, the dependent names are looked
|
| 222 |
+
up, the semantics constraints are checked, and the instantiation of any
|
| 223 |
+
template used in the *exception-specification* is done as if it were
|
| 224 |
+
being done as part of instantiating the declaration of the
|
| 225 |
+
specialization at that point.
|
| 226 |
+
|
| 227 |
[[temp.point]] defines the point of instantiation of a template
|
| 228 |
specialization.
|
| 229 |
|
| 230 |
There is an implementation-defined quantity that specifies the limit on
|
| 231 |
the total depth of recursive instantiations, which could involve more
|