From Jason Turner

[temp.local]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpn5s9wr0o/{from.md → to.md} +34 -71
tmp/tmpn5s9wr0o/{from.md → to.md} RENAMED
@@ -6,18 +6,18 @@ 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
18
- specialization enclosed in `<>`.
19
 
20
  [*Example 1*:
21
 
22
  ``` cpp
23
  template<template<class> class T> class A { };
@@ -34,11 +34,11 @@ template<> class Y<int> {
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
44
  template <class T> struct Base {
@@ -47,12 +47,12 @@ template <class T> struct Base {
47
 
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
@@ -90,96 +90,59 @@ template<class T> class X {
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 {
103
- int T; // error: template-parameter redeclared
104
  void f() {
105
- char T; // error: template-parameter redeclared
106
  }
 
107
  };
108
 
109
- template<class X> class X; // error: template-parameter redeclared
110
  ```
111
 
112
  — *end example*]
113
 
114
- In the definition of a member of a class template that appears outside
115
- of the class template definition, the name of a member of the class
116
- template hides the name of a *template-parameter* of any enclosing class
117
- templates (but not a *template-parameter* of the member if the member is
118
- a class or function template).
 
 
 
119
 
120
  [*Example 6*:
121
 
122
  ``` cpp
123
- template<class T> struct A {
124
- struct B { ... };
 
 
125
  typedef void C;
126
  void f();
127
  template<class U> void g(U);
128
  };
129
-
130
- template<class B> void A<B>::f() {
131
- B b; // A's B, not the template parameter
132
  }
133
 
134
- template<class B> template<class C> void A<B>::g(C) {
135
- B b; // A's B, not the template parameter
136
- C c; // the template parameter C, not A's C
137
  }
138
- ```
139
-
140
- — *end example*]
141
 
142
- In the definition of a member of a class template that appears outside
143
- of the namespace containing the class template definition, the name of a
144
- *template-parameter* hides the name of a member of this namespace.
145
-
146
- [*Example 7*:
147
-
148
- ``` cpp
149
- namespace N {
150
- class C { };
151
- template<class T> class B {
152
- void f(T);
153
- };
154
- }
155
- template<class C> void N::B<C>::f(C) {
156
- C b; // C is the template parameter, not N::C
157
  }
158
  ```
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 {
173
- struct B { ... };
174
- int a;
175
- int Y;
176
- };
177
-
178
- template<class B, class a> struct X : A {
179
- B b; // A's B
180
- a b; // error: A's a isn't a type name
181
- };
182
- ```
183
-
184
- — *end example*]
185
-
 
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 argument list
12
+ [[temp.decls.general]], [[temp.arg.general]] of the class template
13
+ enclosed in `<>`.
14
 
15
+ When the injected-class-name of a class template specialization or
16
+ partial specialization is used as a *type-name*, it is equivalent to the
17
+ *template-name* followed by the *template-argument*s of the class
18
+ template specialization or partial specialization enclosed in `<>`.
 
19
 
20
  [*Example 1*:
21
 
22
  ``` cpp
23
  template<template<class> class T> class A { };
 
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 named.
40
 
41
  [*Example 2*:
42
 
43
  ``` cpp
44
  template <class T> struct Base {
 
47
 
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::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
 
90
  };
91
  ```
92
 
93
  — *end example*]
94
 
95
+ The name of a *template-parameter* shall not be bound to any following
96
+ declaration whose locus is contained by the scope to which the
97
+ template-parameter belongs.
98
 
99
  [*Example 5*:
100
 
101
  ``` cpp
102
  template<class T, int i> class Y {
103
+ int T; // error: template-parameter hidden
104
  void f() {
105
+ char T; // error: template-parameter hidden
106
  }
107
+ friend void T(); // OK, no name bound
108
  };
109
 
110
+ template<class X> class X; // error: hidden by template-parameter
111
  ```
112
 
113
  — *end example*]
114
 
115
+ Unqualified name lookup considers the template parameter scope of a
116
+ *template-declaration* immediately after the outermost scope associated
117
+ with the template declared (even if its parent scope does not contain
118
+ the *template-parameter-list*).
119
+
120
+ [*Note 1*: The scope of a class template, including its non-dependent
121
+ base classes [[temp.dep.type]], [[class.member.lookup]], is searched
122
+ before its template parameter scope. — *end note*]
123
 
124
  [*Example 6*:
125
 
126
  ``` cpp
127
+ struct B { };
128
+ namespace N {
129
+ typedef void V;
130
+ template<class T> struct A : B {
131
  typedef void C;
132
  void f();
133
  template<class U> void g(U);
134
  };
 
 
 
135
  }
136
 
137
+ template<class V> void N::A<V>::f() { // N::V not considered here
138
+ V v; // V is still the template parameter, not N::V
 
139
  }
 
 
 
140
 
141
+ template<class B> template<class C> void N::A<B>::g(C) {
142
+ B b; // B is the base class, not the template parameter
143
+ C c; // C is the template parameter, not A's C
 
 
 
 
 
 
 
 
 
 
 
 
144
  }
145
  ```
146
 
147
  — *end example*]
148