tmp/tmpqnib5a86/{from.md → to.md}
RENAMED
|
@@ -1,16 +1,17 @@
|
|
| 1 |
### Locally declared names <a id="temp.local">[[temp.local]]</a>
|
| 2 |
|
| 3 |
Like normal (non-template) classes, class templates have an
|
| 4 |
-
injected-class-name
|
| 5 |
-
|
| 6 |
*template-argument-list*, as a *template-argument* for a template
|
| 7 |
*template-parameter*, or as the final identifier in the
|
| 8 |
*elaborated-type-specifier* of a friend class template declaration, it
|
| 9 |
-
refers to the class template itself.
|
| 10 |
-
*
|
| 11 |
-
template enclosed in
|
|
|
|
| 12 |
|
| 13 |
Within the scope of a class template specialization or partial
|
| 14 |
specialization, when the injected-class-name is used as a *type-name*,
|
| 15 |
it is equivalent to the *template-name* followed by the
|
| 16 |
*template-argument*s of the class template specialization or partial
|
|
@@ -32,11 +33,11 @@ template<> class Y<int> {
|
|
| 32 |
```
|
| 33 |
|
| 34 |
— *end example*]
|
| 35 |
|
| 36 |
The injected-class-name of a class template or class template
|
| 37 |
-
specialization can be used
|
| 38 |
wherever it is in scope.
|
| 39 |
|
| 40 |
[*Example 2*:
|
| 41 |
|
| 42 |
``` cpp
|
|
@@ -47,20 +48,20 @@ template <class T> struct Base {
|
|
| 47 |
template <class T> struct Derived: public Base<T> {
|
| 48 |
typename Derived::Base* p; // meaning Derived::Base<T>
|
| 49 |
};
|
| 50 |
|
| 51 |
template<class T, template<class> class U = T::template Base> struct Third { };
|
| 52 |
-
Third<
|
| 53 |
```
|
| 54 |
|
| 55 |
— *end example*]
|
| 56 |
|
| 57 |
-
A lookup that finds an injected-class-name
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
template itself and not a specialization thereof, and is not ambiguous.
|
| 63 |
|
| 64 |
[*Example 3*:
|
| 65 |
|
| 66 |
``` cpp
|
|
@@ -89,13 +90,13 @@ template<class T> class X {
|
|
| 89 |
};
|
| 90 |
```
|
| 91 |
|
| 92 |
— *end example*]
|
| 93 |
|
| 94 |
-
|
| 95 |
-
(including nested scopes). A *template-parameter* shall not have
|
| 96 |
-
same name as the template name.
|
| 97 |
|
| 98 |
[*Example 5*:
|
| 99 |
|
| 100 |
``` cpp
|
| 101 |
template<class T, int i> class Y {
|
|
@@ -158,14 +159,14 @@ template<class C> void N::B<C>::f(C) {
|
|
| 158 |
|
| 159 |
— *end example*]
|
| 160 |
|
| 161 |
In the definition of a class template or in the definition of a member
|
| 162 |
of such a template that appears outside of the template definition, for
|
| 163 |
-
each non-dependent base class
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
|
| 168 |
[*Example 8*:
|
| 169 |
|
| 170 |
``` cpp
|
| 171 |
struct A {
|
|
|
|
| 1 |
### Locally declared names <a id="temp.local">[[temp.local]]</a>
|
| 2 |
|
| 3 |
Like normal (non-template) classes, class templates have an
|
| 4 |
+
injected-class-name [[class.pre]]. The injected-class-name can be used
|
| 5 |
+
as a *template-name* or a *type-name*. When it is used with a
|
| 6 |
*template-argument-list*, as a *template-argument* for a template
|
| 7 |
*template-parameter*, or as the final identifier in the
|
| 8 |
*elaborated-type-specifier* of a friend class template declaration, it
|
| 9 |
+
is a *template-name* that refers to the class template itself.
|
| 10 |
+
Otherwise, it is a *type-name* equivalent to the *template-name*
|
| 11 |
+
followed by the *template-parameter*s of the class template enclosed in
|
| 12 |
+
`<>`.
|
| 13 |
|
| 14 |
Within the scope of a class template specialization or partial
|
| 15 |
specialization, when the injected-class-name is used as a *type-name*,
|
| 16 |
it is equivalent to the *template-name* followed by the
|
| 17 |
*template-argument*s of the class template specialization or partial
|
|
|
|
| 33 |
```
|
| 34 |
|
| 35 |
— *end example*]
|
| 36 |
|
| 37 |
The injected-class-name of a class template or class template
|
| 38 |
+
specialization can be used as either a *template-name* or a *type-name*
|
| 39 |
wherever it is in scope.
|
| 40 |
|
| 41 |
[*Example 2*:
|
| 42 |
|
| 43 |
``` cpp
|
|
|
|
| 48 |
template <class T> struct Derived: public Base<T> {
|
| 49 |
typename Derived::Base* p; // meaning Derived::Base<T>
|
| 50 |
};
|
| 51 |
|
| 52 |
template<class T, template<class> class U = T::template Base> struct Third { };
|
| 53 |
+
Third<Derived<int> > t; // OK: default argument uses injected-class-name as a template
|
| 54 |
```
|
| 55 |
|
| 56 |
— *end example*]
|
| 57 |
|
| 58 |
+
A lookup that finds an injected-class-name [[class.member.lookup]] can
|
| 59 |
+
result in an ambiguity in certain cases (for example, if it is found in
|
| 60 |
+
more than one base class). If all of the injected-class-names that are
|
| 61 |
+
found refer to specializations of the same class template, and if the
|
| 62 |
+
name is used as a *template-name*, the reference refers to the class
|
| 63 |
template itself and not a specialization thereof, and is not ambiguous.
|
| 64 |
|
| 65 |
[*Example 3*:
|
| 66 |
|
| 67 |
``` cpp
|
|
|
|
| 90 |
};
|
| 91 |
```
|
| 92 |
|
| 93 |
— *end example*]
|
| 94 |
|
| 95 |
+
The name of a *template-parameter* shall not be redeclared within its
|
| 96 |
+
scope (including nested scopes). A *template-parameter* shall not have
|
| 97 |
+
the same name as the template name.
|
| 98 |
|
| 99 |
[*Example 5*:
|
| 100 |
|
| 101 |
``` cpp
|
| 102 |
template<class T, int i> class Y {
|
|
|
|
| 159 |
|
| 160 |
— *end example*]
|
| 161 |
|
| 162 |
In the definition of a class template or in the definition of a member
|
| 163 |
of such a template that appears outside of the template definition, for
|
| 164 |
+
each non-dependent base class [[temp.dep.type]], if the name of the base
|
| 165 |
+
class or the name of a member of the base class is the same as the name
|
| 166 |
+
of a *template-parameter*, the base class name or member name hides the
|
| 167 |
+
*template-parameter* name [[basic.scope.hiding]].
|
| 168 |
|
| 169 |
[*Example 8*:
|
| 170 |
|
| 171 |
``` cpp
|
| 172 |
struct A {
|