From Jason Turner

[temp.expl.spec]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp__chfpfq/{from.md → to.md} +43 -35
tmp/tmp__chfpfq/{from.md → to.md} RENAMED
@@ -2,10 +2,11 @@
2
 
3
  An explicit specialization of any of the following:
4
 
5
  - function template
6
  - class template
 
7
  - member function of a class template
8
  - static data member of a class template
9
  - member class of a class template
10
  - member enumeration of a class template
11
  - member class template of a class or class template
@@ -43,33 +44,34 @@ enclosing namespace of the template, or, if the namespace is inline (
43
  [[namespace.def]]), any namespace from its enclosing namespace set. Such
44
  a declaration may also be a definition. If the declaration is not a
45
  definition, the specialization may be defined later (
46
  [[namespace.memdef]]).
47
 
48
- A declaration of a function template or class template being explicitly
49
- specialized shall precede the declaration of the explicit
50
- specialization. A declaration, but not a definition of the template is
51
- required. The definition of a class or class template shall precede the
52
- declaration of an explicit specialization for a member template of the
53
- class or class template.
54
 
55
  ``` cpp
56
  template<> class X<int> { /* ... */ }; // error: X not a template
57
 
58
  template<class T> class X;
59
 
60
  template<> class X<char*> { /* ... */ }; // OK: X is a template
61
  ```
62
 
63
  A member function, a member function template, a member class, a member
64
- enumeration, a member class template, or a static data member of a class
65
- template may be explicitly specialized for a class specialization that
66
- is implicitly instantiated; in this case, the definition of the class
67
- template shall precede the explicit specialization for the member of the
68
- class template. If such an explicit specialization for the member of a
69
- class template names an implicitly-declared special member function
70
- (Clause  [[special]]), the program is ill-formed.
 
71
 
72
  A member of an explicitly specialized class is not implicitly
73
  instantiated from the member declaration of the class template; instead,
74
  the member of the class template specialization shall itself be
75
  explicitly defined if its definition is required. In this case, the
@@ -161,31 +163,33 @@ template<class T> struct A {
161
  };
162
  template<> enum A<int>::E : int { eint }; // OK
163
  template<> enum class A<int>::S : int { sint }; // OK
164
  template<class T> enum A<T>::E : T { eT };
165
  template<class T> enum class A<T>::S : T { sT };
166
- template<> enum A<char>::E : int { echar }; // ill-formed, A<char>::E was instantiated
167
  // when A<char> was instantiated
168
- template<> enum class A<char>::S : int { schar }; // OK
169
  ```
170
 
171
  The placement of explicit specialization declarations for function
172
- templates, class templates, member functions of class templates, static
173
- data members of class templates, member classes of class templates,
174
- member enumerations of class templates, member class templates of class
175
- templates, member function templates of class templates, member
 
176
  functions of member templates of class templates, member functions of
177
- member templates of non-template classes, member function templates of
178
- member classes of class templates, etc., and the placement of partial
179
- specialization declarations of class templates, member class templates
180
- of non-template classes, member class templates of class templates,
181
- etc., can affect whether a program is well-formed according to the
182
- relative positioning of the explicit specialization declarations and
183
- their points of instantiation in the translation unit as specified above
184
- and below. When writing a specialization, be careful about its location;
185
- or to make it compile will be such a trial as to kindle its
186
- self-immolation.
 
187
 
188
  A template explicit specialization is in the scope of the namespace in
189
  which the template was defined.
190
 
191
  ``` cpp
@@ -198,11 +202,13 @@ namespace N {
198
  template<> class Y<double>; // forward declare intent to
199
  // specialize for double
200
  }
201
 
202
  template<> class N::Y<double> { /* ... */ }; // OK: specialization
203
- // in same namespace
 
 
204
  ```
205
 
206
  A *simple-template-id* that names a class template explicit
207
  specialization that has been declared but not defined can be used
208
  exactly like the names of other incompletely-defined classes (
@@ -243,13 +249,14 @@ template<class T> inline T g(T) { /* ... */ }
243
 
244
  template<> inline void f<>(int) { /* ... */ } // OK: inline
245
  template<> int g<>(int) { /* ... */ } // OK: not inline
246
  ```
247
 
248
- An explicit specialization of a static data member of a template is a
249
- definition if the declaration includes an initializer; otherwise, it is
250
- a declaration. The definition of a static data member of a template that
 
251
  requires default initialization must use a *braced-init-list*:
252
 
253
  ``` cpp
254
  template<> X Q<int>::x; // declaration
255
  template<> X Q<int>::x (); // error: declares a function
@@ -332,12 +339,13 @@ template <> template <> template<class T>
332
  template <class Y> template <>
333
  void A<Y>::B<double>::mf2() { } // ill-formed; B<double> is specialized but
334
  // its enclosing class template A is not
335
  ```
336
 
337
- A specialization of a member function template or member class template
338
- of a non-specialized class template is itself a template.
 
339
 
340
  An explicit specialization declaration shall not be a friend
341
  declaration.
342
 
343
  Default function arguments shall not be specified in a declaration or a
 
2
 
3
  An explicit specialization of any of the following:
4
 
5
  - function template
6
  - class template
7
+ - variable template
8
  - member function of a class template
9
  - static data member of a class template
10
  - member class of a class template
11
  - member enumeration of a class template
12
  - member class template of a class or class template
 
44
  [[namespace.def]]), any namespace from its enclosing namespace set. Such
45
  a declaration may also be a definition. If the declaration is not a
46
  definition, the specialization may be defined later (
47
  [[namespace.memdef]]).
48
 
49
+ A declaration of a function template, class template, or variable
50
+ template being explicitly specialized shall precede the declaration of
51
+ the explicit specialization. A declaration, but not a definition of the
52
+ template is required. The definition of a class or class template shall
53
+ precede the declaration of an explicit specialization for a member
54
+ template of the class or class template.
55
 
56
  ``` cpp
57
  template<> class X<int> { /* ... */ }; // error: X not a template
58
 
59
  template<class T> class X;
60
 
61
  template<> class X<char*> { /* ... */ }; // OK: X is a template
62
  ```
63
 
64
  A member function, a member function template, a member class, a member
65
+ enumeration, a member class template, a static data member, or a static
66
+ data member template of a class template may be explicitly specialized
67
+ for a class specialization that is implicitly instantiated; in this
68
+ case, the definition of the class template shall precede the explicit
69
+ specialization for the member of the class template. If such an explicit
70
+ specialization for the member of a class template names an
71
+ implicitly-declared special member function (Clause  [[special]]), the
72
+ program is ill-formed.
73
 
74
  A member of an explicitly specialized class is not implicitly
75
  instantiated from the member declaration of the class template; instead,
76
  the member of the class template specialization shall itself be
77
  explicitly defined if its definition is required. In this case, the
 
163
  };
164
  template<> enum A<int>::E : int { eint }; // OK
165
  template<> enum class A<int>::S : int { sint }; // OK
166
  template<class T> enum A<T>::E : T { eT };
167
  template<class T> enum class A<T>::S : T { sT };
168
+ template<> enum A<char>::E : char { echar }; // ill-formed, A<char>::E was instantiated
169
  // when A<char> was instantiated
170
+ template<> enum class A<char>::S : char { schar }; // OK
171
  ```
172
 
173
  The placement of explicit specialization declarations for function
174
+ templates, class templates, variable templates, member functions of
175
+ class templates, static data members of class templates, member classes
176
+ of class templates, member enumerations of class templates, member class
177
+ templates of class templates, member function templates of class
178
+ templates, static data member templates of class templates, member
179
  functions of member templates of class templates, member functions of
180
+ member templates of non-template classes, static data member templates
181
+ of non-template classes, member function templates of member classes of
182
+ class templates, etc., and the placement of partial specialization
183
+ declarations of class templates, variable templates, member class
184
+ templates of non-template classes, static data member templates of
185
+ non-template classes, member class templates of class templates, etc.,
186
+ can affect whether a program is well-formed according to the relative
187
+ positioning of the explicit specialization declarations and their points
188
+ of instantiation in the translation unit as specified above and below.
189
+ When writing a specialization, be careful about its location; or to make
190
+ it compile will be such a trial as to kindle its self-immolation.
191
 
192
  A template explicit specialization is in the scope of the namespace in
193
  which the template was defined.
194
 
195
  ``` cpp
 
202
  template<> class Y<double>; // forward declare intent to
203
  // specialize for double
204
  }
205
 
206
  template<> class N::Y<double> { /* ... */ }; // OK: specialization
207
+ // in enclosing namespace
208
+ template<> class N::Y<short> { /* ... */ }; // OK: specialization
209
+ // in enclosing namespace
210
  ```
211
 
212
  A *simple-template-id* that names a class template explicit
213
  specialization that has been declared but not defined can be used
214
  exactly like the names of other incompletely-defined classes (
 
249
 
250
  template<> inline void f<>(int) { /* ... */ } // OK: inline
251
  template<> int g<>(int) { /* ... */ } // OK: not inline
252
  ```
253
 
254
+ An explicit specialization of a static data member of a template or an
255
+ explicit specialization of a static data member template is a definition
256
+ if the declaration includes an initializer; otherwise, it is a
257
+ declaration. The definition of a static data member of a template that
258
  requires default initialization must use a *braced-init-list*:
259
 
260
  ``` cpp
261
  template<> X Q<int>::x; // declaration
262
  template<> X Q<int>::x (); // error: declares a function
 
339
  template <class Y> template <>
340
  void A<Y>::B<double>::mf2() { } // ill-formed; B<double> is specialized but
341
  // its enclosing class template A is not
342
  ```
343
 
344
+ A specialization of a member function template, member class template,
345
+ or static data member template of a non-specialized class template is
346
+ itself a template.
347
 
348
  An explicit specialization declaration shall not be a friend
349
  declaration.
350
 
351
  Default function arguments shall not be specified in a declaration or a