tmp/tmpgau1vai1/{from.md → to.md}
RENAMED
|
@@ -2,41 +2,50 @@
|
|
| 2 |
|
| 3 |
A name refers to the *current instantiation* if it is
|
| 4 |
|
| 5 |
- in the definition of a class template, a nested class of a class
|
| 6 |
template, a member of a class template, or a member of a nested class
|
| 7 |
-
of a class template, the injected-class-name
|
| 8 |
-
|
| 9 |
- in the definition of a primary class template or a member of a primary
|
| 10 |
class template, the name of the class template followed by the
|
| 11 |
template argument list of the primary template (as described below)
|
| 12 |
enclosed in `<>` (or an equivalent template alias specialization),
|
| 13 |
- in the definition of a nested class of a class template, the name of
|
| 14 |
the nested class referenced as a member of the current instantiation,
|
| 15 |
or
|
| 16 |
- in the definition of a partial specialization or a member of a partial
|
| 17 |
specialization, the name of the class template followed by the
|
| 18 |
template argument list of the partial specialization enclosed in `<>`
|
| 19 |
-
(or an equivalent template alias specialization). If the
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
parameter pack.
|
| 23 |
|
| 24 |
The template argument list of a primary template is a template argument
|
| 25 |
-
list in which the
|
| 26 |
-
template parameter of the class template. If the
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
-
A template argument that is equivalent to a template parameter
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
[*Example 1*:
|
| 40 |
|
| 41 |
``` cpp
|
| 42 |
template <class T> class A {
|
|
@@ -61,22 +70,26 @@ template <class T1, class T2, int I> struct B {
|
|
| 61 |
B<T2, T1, I>* b2; // not the current instantiation
|
| 62 |
typedef T1 my_T1;
|
| 63 |
static const int my_I = I;
|
| 64 |
static const int my_I2 = I+0;
|
| 65 |
static const int my_I3 = my_I;
|
|
|
|
|
|
|
| 66 |
B<my_T1, T2, my_I>* b3; // refers to the current instantiation
|
| 67 |
B<my_T1, T2, my_I2>* b4; // not the current instantiation
|
| 68 |
B<my_T1, T2, my_I3>* b5; // refers to the current instantiation
|
|
|
|
|
|
|
| 69 |
};
|
| 70 |
```
|
| 71 |
|
| 72 |
— *end example*]
|
| 73 |
|
| 74 |
A *dependent base class* is a base class that is a dependent type and is
|
| 75 |
not the current instantiation.
|
| 76 |
|
| 77 |
-
[*Note
|
| 78 |
|
| 79 |
A base class can be the current instantiation in the case of a nested
|
| 80 |
class naming an enclosing class as a base.
|
| 81 |
|
| 82 |
[*Example 2*:
|
|
@@ -101,26 +114,26 @@ template<class T> struct A<T>::B::C : A<T> {
|
|
| 101 |
|
| 102 |
A name is a *member of the current instantiation* if it is
|
| 103 |
|
| 104 |
- An unqualified name that, when looked up, refers to at least one
|
| 105 |
member of a class that is the current instantiation or a non-dependent
|
| 106 |
-
base class thereof. \[*Note
|
| 107 |
name in a scope enclosed by the definition of a class
|
| 108 |
template. — *end note*]
|
| 109 |
- A *qualified-id* in which the *nested-name-specifier* refers to the
|
| 110 |
current instantiation and that, when looked up, refers to at least one
|
| 111 |
member of a class that is the current instantiation or a non-dependent
|
| 112 |
-
base class thereof. \[*Note
|
| 113 |
current instantiation has any dependent base classes, then the
|
| 114 |
*qualified-id* is a member of an unknown specialization; see
|
| 115 |
below. — *end note*]
|
| 116 |
- An *id-expression* denoting the member in a class member access
|
| 117 |
-
expression
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
thereof. \[*Note
|
| 122 |
instantiation has any dependent base classes, then the *id-expression*
|
| 123 |
is a member of an unknown specialization; see below. — *end note*]
|
| 124 |
|
| 125 |
[*Example 3*:
|
| 126 |
|
|
@@ -152,18 +165,18 @@ A name is a *member of an unknown specialization* if it is
|
|
| 152 |
current instantiation, the current instantiation has at least one
|
| 153 |
dependent base class, and name lookup of the *qualified-id* does not
|
| 154 |
find any member of a class that is the current instantiation or a
|
| 155 |
non-dependent base class thereof.
|
| 156 |
- An *id-expression* denoting the member in a class member access
|
| 157 |
-
expression
|
| 158 |
- the type of the object expression is the current instantiation, the
|
| 159 |
current instantiation has at least one dependent base class, and
|
| 160 |
name lookup of the *id-expression* does not find a member of a class
|
| 161 |
that is the current instantiation or a non-dependent base class
|
| 162 |
thereof; or
|
| 163 |
-
- the type of the object expression is
|
| 164 |
-
|
| 165 |
|
| 166 |
If a *qualified-id* in which the *nested-name-specifier* refers to the
|
| 167 |
current instantiation is not a member of the current instantiation or a
|
| 168 |
member of an unknown specialization, the program is ill-formed even if
|
| 169 |
the template containing the *qualified-id* is not instantiated; no
|
|
@@ -230,19 +243,19 @@ A type is dependent if it is
|
|
| 230 |
- a cv-qualified type where the cv-unqualified type is dependent,
|
| 231 |
- a compound type constructed from any dependent type,
|
| 232 |
- an array type whose element type is dependent or whose bound (if any)
|
| 233 |
is value-dependent,
|
| 234 |
- a function type whose exception specification is value-dependent,
|
| 235 |
-
- a *simple-template-id* in which either the template name is
|
| 236 |
-
parameter or any of the template arguments is a dependent
|
| 237 |
-
expression that is type-dependent or value-dependent or is
|
| 238 |
-
expansion \[*Note
|
| 239 |
-
[[class]]
|
| 240 |
*template-argument-list*. — *end note*] , or
|
| 241 |
- denoted by `decltype(`*expression*`)`, where *expression* is
|
| 242 |
-
type-dependent
|
| 243 |
|
| 244 |
-
[*Note
|
| 245 |
simply refer to other types, a name that refers to a typedef that is a
|
| 246 |
member of the current instantiation is dependent only if the type
|
| 247 |
referred to is dependent. — *end note*]
|
| 248 |
|
|
|
|
| 2 |
|
| 3 |
A name refers to the *current instantiation* if it is
|
| 4 |
|
| 5 |
- in the definition of a class template, a nested class of a class
|
| 6 |
template, a member of a class template, or a member of a nested class
|
| 7 |
+
of a class template, the injected-class-name [[class.pre]] of the
|
| 8 |
+
class template or nested class,
|
| 9 |
- in the definition of a primary class template or a member of a primary
|
| 10 |
class template, the name of the class template followed by the
|
| 11 |
template argument list of the primary template (as described below)
|
| 12 |
enclosed in `<>` (or an equivalent template alias specialization),
|
| 13 |
- in the definition of a nested class of a class template, the name of
|
| 14 |
the nested class referenced as a member of the current instantiation,
|
| 15 |
or
|
| 16 |
- in the definition of a partial specialization or a member of a partial
|
| 17 |
specialization, the name of the class template followed by the
|
| 18 |
template argument list of the partial specialization enclosed in `<>`
|
| 19 |
+
(or an equivalent template alias specialization). If the nᵗʰ template
|
| 20 |
+
parameter is a template parameter pack, the nᵗʰ template argument is a
|
| 21 |
+
pack expansion [[temp.variadic]] whose pattern is the name of the
|
| 22 |
+
template parameter pack.
|
| 23 |
|
| 24 |
The template argument list of a primary template is a template argument
|
| 25 |
+
list in which the nᵗʰ template argument has the value of the nᵗʰ
|
| 26 |
+
template parameter of the class template. If the nᵗʰ template parameter
|
| 27 |
+
is a template parameter pack [[temp.variadic]], the nᵗʰ template
|
| 28 |
+
argument is a pack expansion [[temp.variadic]] whose pattern is the name
|
| 29 |
+
of the template parameter pack.
|
| 30 |
|
| 31 |
+
A template argument that is equivalent to a template parameter can be
|
| 32 |
+
used in place of that template parameter in a reference to the current
|
| 33 |
+
instantiation. For a template *type-parameter*, a template argument is
|
| 34 |
+
equivalent to a template parameter if it denotes the same type. For a
|
| 35 |
+
non-type template parameter, a template argument is equivalent to a
|
| 36 |
+
template parameter if it is an *identifier* that names a variable that
|
| 37 |
+
is equivalent to the template parameter. A variable is equivalent to a
|
| 38 |
+
template parameter if
|
| 39 |
+
|
| 40 |
+
- it has the same type as the template parameter (ignoring
|
| 41 |
+
cv-qualification) and
|
| 42 |
+
- its initializer consists of a single *identifier* that names the
|
| 43 |
+
template parameter or, recursively, such a variable.
|
| 44 |
+
|
| 45 |
+
[*Note 1*: Using a parenthesized variable name breaks the
|
| 46 |
+
equivalence. — *end note*]
|
| 47 |
|
| 48 |
[*Example 1*:
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
template <class T> class A {
|
|
|
|
| 70 |
B<T2, T1, I>* b2; // not the current instantiation
|
| 71 |
typedef T1 my_T1;
|
| 72 |
static const int my_I = I;
|
| 73 |
static const int my_I2 = I+0;
|
| 74 |
static const int my_I3 = my_I;
|
| 75 |
+
static const long my_I4 = I;
|
| 76 |
+
static const int my_I5 = (I);
|
| 77 |
B<my_T1, T2, my_I>* b3; // refers to the current instantiation
|
| 78 |
B<my_T1, T2, my_I2>* b4; // not the current instantiation
|
| 79 |
B<my_T1, T2, my_I3>* b5; // refers to the current instantiation
|
| 80 |
+
B<my_T1, T2, my_I4>* b6; // not the current instantiation
|
| 81 |
+
B<my_T1, T2, my_I5>* b7; // not the current instantiation
|
| 82 |
};
|
| 83 |
```
|
| 84 |
|
| 85 |
— *end example*]
|
| 86 |
|
| 87 |
A *dependent base class* is a base class that is a dependent type and is
|
| 88 |
not the current instantiation.
|
| 89 |
|
| 90 |
+
[*Note 2*:
|
| 91 |
|
| 92 |
A base class can be the current instantiation in the case of a nested
|
| 93 |
class naming an enclosing class as a base.
|
| 94 |
|
| 95 |
[*Example 2*:
|
|
|
|
| 114 |
|
| 115 |
A name is a *member of the current instantiation* if it is
|
| 116 |
|
| 117 |
- An unqualified name that, when looked up, refers to at least one
|
| 118 |
member of a class that is the current instantiation or a non-dependent
|
| 119 |
+
base class thereof. \[*Note 3*: This can only occur when looking up a
|
| 120 |
name in a scope enclosed by the definition of a class
|
| 121 |
template. — *end note*]
|
| 122 |
- A *qualified-id* in which the *nested-name-specifier* refers to the
|
| 123 |
current instantiation and that, when looked up, refers to at least one
|
| 124 |
member of a class that is the current instantiation or a non-dependent
|
| 125 |
+
base class thereof. \[*Note 4*: If no such member is found, and the
|
| 126 |
current instantiation has any dependent base classes, then the
|
| 127 |
*qualified-id* is a member of an unknown specialization; see
|
| 128 |
below. — *end note*]
|
| 129 |
- An *id-expression* denoting the member in a class member access
|
| 130 |
+
expression [[expr.ref]] for which the type of the object expression is
|
| 131 |
+
the current instantiation, and the *id-expression*, when looked up
|
| 132 |
+
[[basic.lookup.classref]], refers to at least one member of a class
|
| 133 |
+
that is the current instantiation or a non-dependent base class
|
| 134 |
+
thereof. \[*Note 5*: If no such member is found, and the current
|
| 135 |
instantiation has any dependent base classes, then the *id-expression*
|
| 136 |
is a member of an unknown specialization; see below. — *end note*]
|
| 137 |
|
| 138 |
[*Example 3*:
|
| 139 |
|
|
|
|
| 165 |
current instantiation, the current instantiation has at least one
|
| 166 |
dependent base class, and name lookup of the *qualified-id* does not
|
| 167 |
find any member of a class that is the current instantiation or a
|
| 168 |
non-dependent base class thereof.
|
| 169 |
- An *id-expression* denoting the member in a class member access
|
| 170 |
+
expression [[expr.ref]] in which either
|
| 171 |
- the type of the object expression is the current instantiation, the
|
| 172 |
current instantiation has at least one dependent base class, and
|
| 173 |
name lookup of the *id-expression* does not find a member of a class
|
| 174 |
that is the current instantiation or a non-dependent base class
|
| 175 |
thereof; or
|
| 176 |
+
- the type of the object expression is not the current instantiation
|
| 177 |
+
and the object expression is type-dependent.
|
| 178 |
|
| 179 |
If a *qualified-id* in which the *nested-name-specifier* refers to the
|
| 180 |
current instantiation is not a member of the current instantiation or a
|
| 181 |
member of an unknown specialization, the program is ill-formed even if
|
| 182 |
the template containing the *qualified-id* is not instantiated; no
|
|
|
|
| 243 |
- a cv-qualified type where the cv-unqualified type is dependent,
|
| 244 |
- a compound type constructed from any dependent type,
|
| 245 |
- an array type whose element type is dependent or whose bound (if any)
|
| 246 |
is value-dependent,
|
| 247 |
- a function type whose exception specification is value-dependent,
|
| 248 |
+
- denoted by a *simple-template-id* in which either the template name is
|
| 249 |
+
a template parameter or any of the template arguments is a dependent
|
| 250 |
+
type or an expression that is type-dependent or value-dependent or is
|
| 251 |
+
a pack expansion \[*Note 6*: This includes an injected-class-name
|
| 252 |
+
[[class.pre]] of a class template used without a
|
| 253 |
*template-argument-list*. — *end note*] , or
|
| 254 |
- denoted by `decltype(`*expression*`)`, where *expression* is
|
| 255 |
+
type-dependent [[temp.dep.expr]].
|
| 256 |
|
| 257 |
+
[*Note 7*: Because typedefs do not introduce new types, but instead
|
| 258 |
simply refer to other types, a name that refers to a typedef that is a
|
| 259 |
member of the current instantiation is dependent only if the type
|
| 260 |
referred to is dependent. — *end note*]
|
| 261 |
|