From Jason Turner

[temp.spec]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpsk_2_auf/{from.md → to.md} +141 -107
tmp/tmpsk_2_auf/{from.md → to.md} RENAMED
@@ -86,18 +86,19 @@ instantiated ([[temp.explicit]]) or explicitly specialized (
86
  [[temp.expl.spec]]), the class template specialization is implicitly
87
  instantiated when the specialization is referenced in a context that
88
  requires a completely-defined object type or when the completeness of
89
  the class type affects the semantics of the program. The implicit
90
  instantiation of a class template specialization causes the implicit
91
- instantiation of the declarations, but not of the definitions or default
92
- arguments, of the class member functions, member classes, scoped member
93
- enumerations, static data members and member templates; and it causes
94
- the implicit instantiation of the definitions of unscoped member
95
- enumerations and member anonymous unions. However, for the purpose of
96
- determining whether an instantiated redeclaration of a member is valid
97
- according to  [[class.mem]], a declaration that corresponds to a
98
- definition in the template is considered to be a definition.
 
99
 
100
  ``` cpp
101
  template<class T, class U>
102
  struct Outer {
103
  template<class X, class Y> struct Inner;
@@ -152,10 +153,17 @@ void h() {
152
  ```
153
 
154
  Nothing in this example requires `class` `Z<double>`, `Z<int>::g()`, or
155
  `Z<char>::f()` to be implicitly instantiated.
156
 
 
 
 
 
 
 
 
157
  A class template specialization is implicitly instantiated if the class
158
  type is used in a context that requires a completely-defined object type
159
  or if the completeness of the class type might affect the semantics of
160
  the program. In particular, if the semantics of an expression depend on
161
  the member or base class lists of a class template specialization, the
@@ -215,28 +223,28 @@ data members of that class to be implicitly instantiated.
215
  If a function template or a member function template specialization is
216
  used in a way that involves overload resolution, a declaration of the
217
  specialization is implicitly instantiated ([[temp.over]]).
218
 
219
  An implementation shall not implicitly instantiate a function template,
220
- a member template, a non-virtual member function, a member class, or a
221
- static data member of a class template that does not require
222
- instantiation. It is unspecified whether or not an implementation
223
- implicitly instantiates a virtual member function of a class template if
224
- the virtual member function would not otherwise be instantiated. The use
225
- of a template specialization in a default argument shall not cause the
226
- template to be implicitly instantiated except that a class template may
227
- be instantiated where its complete type is needed to determine the
228
- correctness of the default argument. The use of a default argument in a
229
- function call causes specializations in the default argument to be
230
- implicitly instantiated.
231
 
232
- Implicitly instantiated class and function template specializations are
233
- placed in the namespace where the template is defined. Implicitly
234
- instantiated specializations for members of a class template are placed
235
- in the namespace where the enclosing class template is defined.
236
- Implicitly instantiated member templates are placed in the namespace
237
- where the enclosing class or class template is defined.
238
 
239
  ``` cpp
240
  namespace N {
241
  template<class T> class List {
242
  public:
@@ -263,13 +271,16 @@ If a function template `f` is called in a way that requires a default
263
  argument to be used, the dependent names are looked up, the semantics
264
  constraints are checked, and the instantiation of any template used in
265
  the default argument is done as if the default argument had been an
266
  initializer used in a function template specialization with the same
267
  scope, the same template parameters and the same access as that of the
268
- function template `f` used at that point. This analysis is called
269
- *default argument instantiation*. The instantiated default argument is
270
- then used as the argument of `f`.
 
 
 
271
 
272
  Each default argument is instantiated independently.
273
 
274
  ``` cpp
275
  template<class T> void f(T x, T y = ydef(T()), T z = zdef(T()));
@@ -283,10 +294,19 @@ void g(A a, A b, A c) {
283
  f(a, b); // default argument z = zdef(T()) instantiated
284
  f(a); // ill-formed; ydef is not declared
285
  }
286
  ```
287
 
 
 
 
 
 
 
 
 
 
288
  [[temp.point]] defines the point of instantiation of a template
289
  specialization.
290
 
291
  There is an implementation-defined quantity that specifies the limit on
292
  the total depth of recursive instantiations, which could involve more
@@ -302,16 +322,17 @@ template<class T> class X {
302
  };
303
  ```
304
 
305
  ### Explicit instantiation <a id="temp.explicit">[[temp.explicit]]</a>
306
 
307
- A class, a function or member template specialization can be explicitly
308
- instantiated from its template. A member function, member class or
309
- static data member of a class template can be explicitly instantiated
310
- from the member definition associated with its class template. An
311
- explicit instantiation of a function template or member function of a
312
- class template shall not use the `inline` or `constexpr` specifiers.
 
313
 
314
  The syntax for explicit instantiation is:
315
 
316
  ``` bnf
317
  explicit-instantiation:
@@ -331,17 +352,18 @@ a *template-name* or *operator-function-id*. The declaration may declare
331
  a *qualified-id*, in which case the *unqualified-id* of the
332
  *qualified-id* must be a *template-id*. If the explicit instantiation is
333
  for a member function, a member class or a static data member of a class
334
  template specialization, the name of the class template specialization
335
  in the *qualified-id* for the member name shall be a
336
- *simple-template-id*. An explicit instantiation shall appear in an
337
- enclosing namespace of its template. If the name declared in the
338
- explicit instantiation is an unqualified name, the explicit
339
- instantiation shall appear in the namespace where its template is
340
- declared or, if that namespace is inline ([[namespace.def]]), any
341
- namespace from its enclosing namespace set. Regarding qualified names in
342
- declarators, see  [[dcl.meaning]].
 
343
 
344
  ``` cpp
345
  template<class T> class Array { void mf(); };
346
  template class Array<char>;
347
  template void Array<int>::mf();
@@ -353,35 +375,36 @@ namespace N {
353
  template<class T> void f(T&) { }
354
  }
355
  template void N::f<int>(int&);
356
  ```
357
 
358
- A declaration of a function template, a member function or static data
359
- member of a class template, or a member function template of a class or
360
- class template shall precede an explicit instantiation of that entity. A
361
- definition of a class template, a member class of a class template, or a
362
- member class template of a class or class template shall precede an
363
- explicit instantiation of that entity unless the explicit instantiation
364
- is preceded by an explicit specialization of the entity with the same
365
- template arguments. If the *declaration* of the explicit instantiation
366
- names an implicitly-declared special member function (Clause 
367
- [[special]]), the program is ill-formed.
 
368
 
369
  For a given set of template arguments, if an explicit instantiation of a
370
  template appears after a declaration of an explicit specialization for
371
  that template, the explicit instantiation has no effect. Otherwise, for
372
  an explicit instantiation definition the definition of a function
373
- template, a member function template, or a member function or static
374
- data member of a class template shall be present in every translation
375
- unit in which it is explicitly instantiated.
376
 
377
- An explicit instantiation of a class or function template specialization
378
- is placed in the namespace in which the template is defined. An explicit
379
- instantiation for a member of a class template is placed in the
380
- namespace where the enclosing class template is defined. An explicit
381
- instantiation for a member template is placed in the namespace where the
382
- enclosing class or class template is defined.
383
 
384
  ``` cpp
385
  namespace N {
386
  template<class T> class Y { void mf() { } };
387
  }
@@ -412,28 +435,31 @@ template void sort<>(Array<int>&);
412
  ```
413
 
414
  An explicit instantiation that names a class template specialization is
415
  also an explicit instantiation of the same kind (declaration or
416
  definition) of each of its members (not including members inherited from
417
- base classes) that has not been previously explicitly specialized in the
418
- translation unit containing the explicit instantiation, except as
419
- described below. In addition, it will typically be an explicit
420
- instantiation of certain implementation-dependent data about the class.
 
421
 
422
  An explicit instantiation definition that names a class template
423
  specialization explicitly instantiates the class template specialization
424
  and is an explicit instantiation definition of only those members that
425
  have been defined at the point of instantiation.
426
 
427
- Except for inline functions and class template specializations, explicit
428
- instantiation declarations have the effect of suppressing the implicit
429
- instantiation of the entity to which they refer. The intent is that an
430
- inline function that is the subject of an explicit instantiation
431
- declaration will still be implicitly instantiated when odr-used (
432
- [[basic.def.odr]]) so that the body can be considered for inlining, but
433
- that no out-of-line copy of the inline function would be generated in
434
- the translation unit.
 
 
435
 
436
  If an entity is the subject of both an explicit instantiation
437
  declaration and an explicit instantiation definition in the same
438
  translation unit, the definition shall follow the declaration. An entity
439
  that is the subject of an explicit instantiation declaration and that is
@@ -469,10 +495,11 @@ template int g<int>(int); // OK even though &p isn't an int.
469
 
470
  An explicit specialization of any of the following:
471
 
472
  - function template
473
  - class template
 
474
  - member function of a class template
475
  - static data member of a class template
476
  - member class of a class template
477
  - member enumeration of a class template
478
  - member class template of a class or class template
@@ -510,33 +537,34 @@ enclosing namespace of the template, or, if the namespace is inline (
510
  [[namespace.def]]), any namespace from its enclosing namespace set. Such
511
  a declaration may also be a definition. If the declaration is not a
512
  definition, the specialization may be defined later (
513
  [[namespace.memdef]]).
514
 
515
- A declaration of a function template or class template being explicitly
516
- specialized shall precede the declaration of the explicit
517
- specialization. A declaration, but not a definition of the template is
518
- required. The definition of a class or class template shall precede the
519
- declaration of an explicit specialization for a member template of the
520
- class or class template.
521
 
522
  ``` cpp
523
  template<> class X<int> { /* ... */ }; // error: X not a template
524
 
525
  template<class T> class X;
526
 
527
  template<> class X<char*> { /* ... */ }; // OK: X is a template
528
  ```
529
 
530
  A member function, a member function template, a member class, a member
531
- enumeration, a member class template, or a static data member of a class
532
- template may be explicitly specialized for a class specialization that
533
- is implicitly instantiated; in this case, the definition of the class
534
- template shall precede the explicit specialization for the member of the
535
- class template. If such an explicit specialization for the member of a
536
- class template names an implicitly-declared special member function
537
- (Clause  [[special]]), the program is ill-formed.
 
538
 
539
  A member of an explicitly specialized class is not implicitly
540
  instantiated from the member declaration of the class template; instead,
541
  the member of the class template specialization shall itself be
542
  explicitly defined if its definition is required. In this case, the
@@ -628,31 +656,33 @@ template<class T> struct A {
628
  };
629
  template<> enum A<int>::E : int { eint }; // OK
630
  template<> enum class A<int>::S : int { sint }; // OK
631
  template<class T> enum A<T>::E : T { eT };
632
  template<class T> enum class A<T>::S : T { sT };
633
- template<> enum A<char>::E : int { echar }; // ill-formed, A<char>::E was instantiated
634
  // when A<char> was instantiated
635
- template<> enum class A<char>::S : int { schar }; // OK
636
  ```
637
 
638
  The placement of explicit specialization declarations for function
639
- templates, class templates, member functions of class templates, static
640
- data members of class templates, member classes of class templates,
641
- member enumerations of class templates, member class templates of class
642
- templates, member function templates of class templates, member
 
643
  functions of member templates of class templates, member functions of
644
- member templates of non-template classes, member function templates of
645
- member classes of class templates, etc., and the placement of partial
646
- specialization declarations of class templates, member class templates
647
- of non-template classes, member class templates of class templates,
648
- etc., can affect whether a program is well-formed according to the
649
- relative positioning of the explicit specialization declarations and
650
- their points of instantiation in the translation unit as specified above
651
- and below. When writing a specialization, be careful about its location;
652
- or to make it compile will be such a trial as to kindle its
653
- self-immolation.
 
654
 
655
  A template explicit specialization is in the scope of the namespace in
656
  which the template was defined.
657
 
658
  ``` cpp
@@ -665,11 +695,13 @@ namespace N {
665
  template<> class Y<double>; // forward declare intent to
666
  // specialize for double
667
  }
668
 
669
  template<> class N::Y<double> { /* ... */ }; // OK: specialization
670
- // in same namespace
 
 
671
  ```
672
 
673
  A *simple-template-id* that names a class template explicit
674
  specialization that has been declared but not defined can be used
675
  exactly like the names of other incompletely-defined classes (
@@ -710,13 +742,14 @@ template<class T> inline T g(T) { /* ... */ }
710
 
711
  template<> inline void f<>(int) { /* ... */ } // OK: inline
712
  template<> int g<>(int) { /* ... */ } // OK: not inline
713
  ```
714
 
715
- An explicit specialization of a static data member of a template is a
716
- definition if the declaration includes an initializer; otherwise, it is
717
- a declaration. The definition of a static data member of a template that
 
718
  requires default initialization must use a *braced-init-list*:
719
 
720
  ``` cpp
721
  template<> X Q<int>::x; // declaration
722
  template<> X Q<int>::x (); // error: declares a function
@@ -799,12 +832,13 @@ template <> template <> template<class T>
799
  template <class Y> template <>
800
  void A<Y>::B<double>::mf2() { } // ill-formed; B<double> is specialized but
801
  // its enclosing class template A is not
802
  ```
803
 
804
- A specialization of a member function template or member class template
805
- of a non-specialized class template is itself a template.
 
806
 
807
  An explicit specialization declaration shall not be a friend
808
  declaration.
809
 
810
  Default function arguments shall not be specified in a declaration or a
 
86
  [[temp.expl.spec]]), the class template specialization is implicitly
87
  instantiated when the specialization is referenced in a context that
88
  requires a completely-defined object type or when the completeness of
89
  the class type affects the semantics of the program. The implicit
90
  instantiation of a class template specialization causes the implicit
91
+ instantiation of the declarations, but not of the definitions, default
92
+ arguments, or *exception-specification*s of the class member functions,
93
+ member classes, scoped member enumerations, static data members and
94
+ member templates; and it causes the implicit instantiation of the
95
+ definitions of unscoped member enumerations and member anonymous unions.
96
+ However, for the purpose of determining whether an instantiated
97
+ redeclaration of a member is valid according to  [[class.mem]], a
98
+ declaration that corresponds to a definition in the template is
99
+ considered to be a definition.
100
 
101
  ``` cpp
102
  template<class T, class U>
103
  struct Outer {
104
  template<class X, class Y> struct Inner;
 
153
  ```
154
 
155
  Nothing in this example requires `class` `Z<double>`, `Z<int>::g()`, or
156
  `Z<char>::f()` to be implicitly instantiated.
157
 
158
+ Unless a variable template specialization has been explicitly
159
+ instantiated or explicitly specialized, the variable template
160
+ specialization is implicitly instantiated when the specialization is
161
+ used. A default template argument for a variable template is implicitly
162
+ instantiated when the variable template is referenced in a context that
163
+ requires the value of the default argument.
164
+
165
  A class template specialization is implicitly instantiated if the class
166
  type is used in a context that requires a completely-defined object type
167
  or if the completeness of the class type might affect the semantics of
168
  the program. In particular, if the semantics of an expression depend on
169
  the member or base class lists of a class template specialization, the
 
223
  If a function template or a member function template specialization is
224
  used in a way that involves overload resolution, a declaration of the
225
  specialization is implicitly instantiated ([[temp.over]]).
226
 
227
  An implementation shall not implicitly instantiate a function template,
228
+ a variable template, a member template, a non-virtual member function, a
229
+ member class, or a static data member of a class template that does not
230
+ require instantiation. It is unspecified whether or not an
231
+ implementation implicitly instantiates a virtual member function of a
232
+ class template if the virtual member function would not otherwise be
233
+ instantiated. The use of a template specialization in a default argument
234
+ shall not cause the template to be implicitly instantiated except that a
235
+ class template may be instantiated where its complete type is needed to
236
+ determine the correctness of the default argument. The use of a default
237
+ argument in a function call causes specializations in the default
238
+ argument to be implicitly instantiated.
239
 
240
+ Implicitly instantiated class, function, and variable template
241
+ specializations are placed in the namespace where the template is
242
+ defined. Implicitly instantiated specializations for members of a class
243
+ template are placed in the namespace where the enclosing class template
244
+ is defined. Implicitly instantiated member templates are placed in the
245
+ namespace where the enclosing class or class template is defined.
246
 
247
  ``` cpp
248
  namespace N {
249
  template<class T> class List {
250
  public:
 
271
  argument to be used, the dependent names are looked up, the semantics
272
  constraints are checked, and the instantiation of any template used in
273
  the default argument is done as if the default argument had been an
274
  initializer used in a function template specialization with the same
275
  scope, the same template parameters and the same access as that of the
276
+ function template `f` used at that point, except that the scope in which
277
+ a closure type is declared ([[expr.prim.lambda]]) and therefore its
278
+ associated namespaces – remain as determined from the context of the
279
+ definition for the default argument. This analysis is called *default
280
+ argument instantiation*. The instantiated default argument is then used
281
+ as the argument of `f`.
282
 
283
  Each default argument is instantiated independently.
284
 
285
  ``` cpp
286
  template<class T> void f(T x, T y = ydef(T()), T z = zdef(T()));
 
294
  f(a, b); // default argument z = zdef(T()) instantiated
295
  f(a); // ill-formed; ydef is not declared
296
  }
297
  ```
298
 
299
+ The *exception-specification* of a function template specialization is
300
+ not instantiated along with the function declaration; it is instantiated
301
+ when needed ([[except.spec]]). If such an *exception-specification* is
302
+ needed but has not yet been instantiated, the dependent names are looked
303
+ up, the semantics constraints are checked, and the instantiation of any
304
+ template used in the *exception-specification* is done as if it were
305
+ being done as part of instantiating the declaration of the
306
+ specialization at that point.
307
+
308
  [[temp.point]] defines the point of instantiation of a template
309
  specialization.
310
 
311
  There is an implementation-defined quantity that specifies the limit on
312
  the total depth of recursive instantiations, which could involve more
 
322
  };
323
  ```
324
 
325
  ### Explicit instantiation <a id="temp.explicit">[[temp.explicit]]</a>
326
 
327
+ A class, function, variable, or member template specialization can be
328
+ explicitly instantiated from its template. A member function, member
329
+ class or static data member of a class template can be explicitly
330
+ instantiated from the member definition associated with its class
331
+ template. An explicit instantiation of a function template or member
332
+ function of a class template shall not use the `inline` or `constexpr`
333
+ specifiers.
334
 
335
  The syntax for explicit instantiation is:
336
 
337
  ``` bnf
338
  explicit-instantiation:
 
352
  a *qualified-id*, in which case the *unqualified-id* of the
353
  *qualified-id* must be a *template-id*. If the explicit instantiation is
354
  for a member function, a member class or a static data member of a class
355
  template specialization, the name of the class template specialization
356
  in the *qualified-id* for the member name shall be a
357
+ *simple-template-id*. If the explicit instantiation is for a variable,
358
+ the *unqualified-id* in the declaration shall be a *template-id*. An
359
+ explicit instantiation shall appear in an enclosing namespace of its
360
+ template. If the name declared in the explicit instantiation is an
361
+ unqualified name, the explicit instantiation shall appear in the
362
+ namespace where its template is declared or, if that namespace is
363
+ inline ([[namespace.def]]), any namespace from its enclosing namespace
364
+ set. Regarding qualified names in declarators, see  [[dcl.meaning]].
365
 
366
  ``` cpp
367
  template<class T> class Array { void mf(); };
368
  template class Array<char>;
369
  template void Array<int>::mf();
 
375
  template<class T> void f(T&) { }
376
  }
377
  template void N::f<int>(int&);
378
  ```
379
 
380
+ A declaration of a function template, a variable template, a member
381
+ function or static data member of a class template, or a member function
382
+ template of a class or class template shall precede an explicit
383
+ instantiation of that entity. A definition of a class template, a member
384
+ class of a class template, or a member class template of a class or
385
+ class template shall precede an explicit instantiation of that entity
386
+ unless the explicit instantiation is preceded by an explicit
387
+ specialization of the entity with the same template arguments. If the
388
+ *declaration* of the explicit instantiation names an implicitly-declared
389
+ special member function (Clause  [[special]]), the program is
390
+ ill-formed.
391
 
392
  For a given set of template arguments, if an explicit instantiation of a
393
  template appears after a declaration of an explicit specialization for
394
  that template, the explicit instantiation has no effect. Otherwise, for
395
  an explicit instantiation definition the definition of a function
396
+ template, a variable template, a member function template, or a member
397
+ function or static data member of a class template shall be present in
398
+ every translation unit in which it is explicitly instantiated.
399
 
400
+ An explicit instantiation of a class, function template, or variable
401
+ template specialization is placed in the namespace in which the template
402
+ is defined. An explicit instantiation for a member of a class template
403
+ is placed in the namespace where the enclosing class template is
404
+ defined. An explicit instantiation for a member template is placed in
405
+ the namespace where the enclosing class or class template is defined.
406
 
407
  ``` cpp
408
  namespace N {
409
  template<class T> class Y { void mf() { } };
410
  }
 
435
  ```
436
 
437
  An explicit instantiation that names a class template specialization is
438
  also an explicit instantiation of the same kind (declaration or
439
  definition) of each of its members (not including members inherited from
440
+ base classes and members that are templates) that has not been
441
+ previously explicitly specialized in the translation unit containing the
442
+ explicit instantiation, except as described below. In addition, it will
443
+ typically be an explicit instantiation of certain
444
+ implementation-dependent data about the class.
445
 
446
  An explicit instantiation definition that names a class template
447
  specialization explicitly instantiates the class template specialization
448
  and is an explicit instantiation definition of only those members that
449
  have been defined at the point of instantiation.
450
 
451
+ Except for inline functions, declarations with types deduced from their
452
+ initializer or return value ([[dcl.spec.auto]]), `const` variables of
453
+ literal types, variables of reference types, and class template
454
+ specializations, explicit instantiation declarations have the effect of
455
+ suppressing the implicit instantiation of the entity to which they
456
+ refer. The intent is that an inline function that is the subject of an
457
+ explicit instantiation declaration will still be implicitly instantiated
458
+ when odr-used ([[basic.def.odr]]) so that the body can be considered
459
+ for inlining, but that no out-of-line copy of the inline function would
460
+ be generated in the translation unit.
461
 
462
  If an entity is the subject of both an explicit instantiation
463
  declaration and an explicit instantiation definition in the same
464
  translation unit, the definition shall follow the declaration. An entity
465
  that is the subject of an explicit instantiation declaration and that is
 
495
 
496
  An explicit specialization of any of the following:
497
 
498
  - function template
499
  - class template
500
+ - variable template
501
  - member function of a class template
502
  - static data member of a class template
503
  - member class of a class template
504
  - member enumeration of a class template
505
  - member class template of a class or class template
 
537
  [[namespace.def]]), any namespace from its enclosing namespace set. Such
538
  a declaration may also be a definition. If the declaration is not a
539
  definition, the specialization may be defined later (
540
  [[namespace.memdef]]).
541
 
542
+ A declaration of a function template, class template, or variable
543
+ template being explicitly specialized shall precede the declaration of
544
+ the explicit specialization. A declaration, but not a definition of the
545
+ template is required. The definition of a class or class template shall
546
+ precede the declaration of an explicit specialization for a member
547
+ template of the class or class template.
548
 
549
  ``` cpp
550
  template<> class X<int> { /* ... */ }; // error: X not a template
551
 
552
  template<class T> class X;
553
 
554
  template<> class X<char*> { /* ... */ }; // OK: X is a template
555
  ```
556
 
557
  A member function, a member function template, a member class, a member
558
+ enumeration, a member class template, a static data member, or a static
559
+ data member template of a class template may be explicitly specialized
560
+ for a class specialization that is implicitly instantiated; in this
561
+ case, the definition of the class template shall precede the explicit
562
+ specialization for the member of the class template. If such an explicit
563
+ specialization for the member of a class template names an
564
+ implicitly-declared special member function (Clause  [[special]]), the
565
+ program is ill-formed.
566
 
567
  A member of an explicitly specialized class is not implicitly
568
  instantiated from the member declaration of the class template; instead,
569
  the member of the class template specialization shall itself be
570
  explicitly defined if its definition is required. In this case, the
 
656
  };
657
  template<> enum A<int>::E : int { eint }; // OK
658
  template<> enum class A<int>::S : int { sint }; // OK
659
  template<class T> enum A<T>::E : T { eT };
660
  template<class T> enum class A<T>::S : T { sT };
661
+ template<> enum A<char>::E : char { echar }; // ill-formed, A<char>::E was instantiated
662
  // when A<char> was instantiated
663
+ template<> enum class A<char>::S : char { schar }; // OK
664
  ```
665
 
666
  The placement of explicit specialization declarations for function
667
+ templates, class templates, variable templates, member functions of
668
+ class templates, static data members of class templates, member classes
669
+ of class templates, member enumerations of class templates, member class
670
+ templates of class templates, member function templates of class
671
+ templates, static data member templates of class templates, member
672
  functions of member templates of class templates, member functions of
673
+ member templates of non-template classes, static data member templates
674
+ of non-template classes, member function templates of member classes of
675
+ class templates, etc., and the placement of partial specialization
676
+ declarations of class templates, variable templates, member class
677
+ templates of non-template classes, static data member templates of
678
+ non-template classes, member class templates of class templates, etc.,
679
+ can affect whether a program is well-formed according to the relative
680
+ positioning of the explicit specialization declarations and their points
681
+ of instantiation in the translation unit as specified above and below.
682
+ When writing a specialization, be careful about its location; or to make
683
+ it compile will be such a trial as to kindle its self-immolation.
684
 
685
  A template explicit specialization is in the scope of the namespace in
686
  which the template was defined.
687
 
688
  ``` cpp
 
695
  template<> class Y<double>; // forward declare intent to
696
  // specialize for double
697
  }
698
 
699
  template<> class N::Y<double> { /* ... */ }; // OK: specialization
700
+ // in enclosing namespace
701
+ template<> class N::Y<short> { /* ... */ }; // OK: specialization
702
+ // in enclosing namespace
703
  ```
704
 
705
  A *simple-template-id* that names a class template explicit
706
  specialization that has been declared but not defined can be used
707
  exactly like the names of other incompletely-defined classes (
 
742
 
743
  template<> inline void f<>(int) { /* ... */ } // OK: inline
744
  template<> int g<>(int) { /* ... */ } // OK: not inline
745
  ```
746
 
747
+ An explicit specialization of a static data member of a template or an
748
+ explicit specialization of a static data member template is a definition
749
+ if the declaration includes an initializer; otherwise, it is a
750
+ declaration. The definition of a static data member of a template that
751
  requires default initialization must use a *braced-init-list*:
752
 
753
  ``` cpp
754
  template<> X Q<int>::x; // declaration
755
  template<> X Q<int>::x (); // error: declares a function
 
832
  template <class Y> template <>
833
  void A<Y>::B<double>::mf2() { } // ill-formed; B<double> is specialized but
834
  // its enclosing class template A is not
835
  ```
836
 
837
+ A specialization of a member function template, member class template,
838
+ or static data member template of a non-specialized class template is
839
+ itself a template.
840
 
841
  An explicit specialization declaration shall not be a friend
842
  declaration.
843
 
844
  Default function arguments shall not be specified in a declaration or a