From Jason Turner

[temp.res]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp0nnvmpl6/{from.md → to.md} +82 -58
tmp/tmp0nnvmpl6/{from.md → to.md} RENAMED
@@ -126,18 +126,17 @@ template<class T> struct A {
126
  B b; // OK, no typename required
127
  };
128
  ```
129
 
130
  Knowing which names are type names allows the syntax of every template
131
- definition to be checked. No diagnostic shall be issued for a template
132
- definition for which a valid specialization can be generated. If no
133
- valid specialization can be generated for a template definition, and
134
- that template is not instantiated, the template definition is
135
- ill-formed, no diagnostic required. If every valid specialization of a
136
- variadic template requires an empty template parameter pack, the
137
- template definition is ill-formed, no diagnostic required. If a type
138
- used in a non-dependent name is incomplete at the point at which a
139
  template is defined but is complete at the point at which an
140
  instantiation is done, and if the completeness of that type affects
141
  whether or not the program is well-formed or affects the semantics of
142
  the program, the program is ill-formed; no diagnostic is required. If a
143
  template is instantiated, errors will be diagnosed according to the
@@ -228,13 +227,14 @@ void h() {
228
  // by two calls of f(E)
229
  g('a'); // will cause three calls of f(char)
230
  }
231
  ```
232
 
233
- For purposes of name lookup, default arguments of function templates and
234
- default arguments of member functions of class templates are considered
235
- definitions ([[temp.decls]]).
 
236
 
237
  ### Locally declared names <a id="temp.local">[[temp.local]]</a>
238
 
239
  Like normal (non-template) classes, class templates have an
240
  injected-class-name (Clause  [[class]]). The injected-class-name can be
@@ -396,19 +396,19 @@ and/or value of template parameters (as determined by the template
396
  arguments) and this determines the context for name lookup for certain
397
  names. Expressions may be *type-dependent* (on the type of a template
398
  parameter) or *value-dependent* (on the value of a non-type template
399
  parameter). In an expression of the form:
400
 
401
- where the *postfix-expression* is an *id-expression*, the
402
- *id-expression* denotes a *dependent name* if
403
 
404
  - any of the expressions in the *expression-list* is a pack expansion (
405
  [[temp.variadic]]),
406
  - any of the expressions in the *expression-list* is a type-dependent
407
  expression ([[temp.dep.expr]]), or
408
- - if the *unqualified-id* of the *id-expression* is a *template-id* in
409
- which any of the template arguments depends on a template parameter.
410
 
411
  If an operand of an operator is a type-dependent expression, the
412
  operator also denotes a dependent name. Such names are unbound and are
413
  looked up at the point of the template instantiation ([[temp.point]])
414
  in both the context of the template definition and the context of the
@@ -540,27 +540,27 @@ template <class T1, class T2, int I> struct B {
540
  ```
541
 
542
  A name is a *member of the current instantiation* if it is
543
 
544
  - An unqualified name that, when looked up, refers to at least one
545
- member of the current instantiation or a non-dependent base class
546
- thereof. This can only occur when looking up a name in a scope
547
- enclosed by the definition of a class template.
548
  - A *qualified-id* in which the *nested-name-specifier* refers to the
549
  current instantiation and that, when looked up, refers to at least one
550
- member of the current instantiation or a non-dependent base class
551
- thereof. if no such member is found, and the current instantiation has
552
- any dependent base classes, then the *qualified-id* is a member of an
553
- unknown specialization; see below.
554
  - An *id-expression* denoting the member in a class member access
555
  expression ([[expr.ref]]) for which the type of the object expression
556
  is the current instantiation, and the *id-expression*, when looked
557
- up ([[basic.lookup.classref]]), refers to at least one member of the
558
- current instantiation or a non-dependent base class thereof. if no
559
- such member is found, and the current instantiation has any dependent
560
- base classes, then the *id-expression* is a member of an unknown
561
- specialization; see below.
562
 
563
  ``` cpp
564
  template <class T> class A {
565
  static const int i = 5;
566
  int n1[i]; // i refers to a member of the current instantiation
@@ -572,25 +572,30 @@ template <class T> class A {
572
  template <class T> int A<T>::f() {
573
  return i; // i refers to a member of the current instantiation
574
  }
575
  ```
576
 
 
 
 
 
577
  A name is a *member of an unknown specialization* if it is
578
 
579
  - A *qualified-id* in which the *nested-name-specifier* names a
580
  dependent type that is not the current instantiation.
581
  - A *qualified-id* in which the *nested-name-specifier* refers to the
582
  current instantiation, the current instantiation has at least one
583
  dependent base class, and name lookup of the *qualified-id* does not
584
- find any member of the current instantiation or a non-dependent base
585
- class thereof.
586
  - An *id-expression* denoting the member in a class member access
587
  expression ([[expr.ref]]) in which either
588
  - the type of the object expression is the current instantiation, the
589
  current instantiation has at least one dependent base class, and
590
- name lookup of the *id-expression* does not find a member of the
591
- current instantiation or a non-dependent base class thereof; or
 
592
  - the type of the object expression is dependent and is not the
593
  current instantiation.
594
 
595
  If a *qualified-id* in which the *nested-name-specifier* refers to the
596
  current instantiation is not a member of the current instantiation or a
@@ -628,12 +633,12 @@ base class of the current instantiation.
628
 
629
  A type is dependent if it is
630
 
631
  - a template parameter,
632
  - a member of an unknown specialization,
633
- - a nested class or enumeration that is a member of the current
634
- instantiation,
635
  - a cv-qualified type where the cv-unqualified type is dependent,
636
  - a compound type constructed from any dependent type,
637
  - an array type constructed from any dependent type or whose size is
638
  specified by a constant expression that is value-dependent,
639
  - a *simple-template-id* in which either the template name is a template
@@ -659,20 +664,25 @@ dependent ([[temp.dep.type]]).
659
 
660
  An *id-expression* is type-dependent if it contains
661
 
662
  - an *identifier* associated by name lookup with one or more
663
  declarations declared with a dependent type,
 
 
 
 
664
  - a *template-id* that is dependent,
665
  - a *conversion-function-id* that specifies a dependent type, or
666
  - a *nested-name-specifier* or a *qualified-id* that names a member of
667
  an unknown specialization;
668
 
669
- or if it names a static data member of the current instantiation that
670
- has type “array of unknown bound of `T`” for some `T` (
671
- [[temp.static]]). Expressions of the following forms are type-dependent
672
- only if the type specified by the *type-id*, *simple-type-specifier* or
673
- *new-type-id* is dependent, even if any subexpression is type-dependent:
 
674
 
675
  Expressions of the following forms are never type-dependent (because the
676
  type of the expression cannot be dependent):
677
 
678
  For the standard library macro `offsetof`, see  [[support.types]].
@@ -692,16 +702,21 @@ member access expression.
692
  #### Value-dependent expressions <a id="temp.dep.constexpr">[[temp.dep.constexpr]]</a>
693
 
694
  Except as described below, a constant expression is value-dependent if
695
  any subexpression is value-dependent.
696
 
697
- An *identifier* is value-dependent if it is:
698
 
699
- - a name declared with a dependent type,
700
- - the name of a non-type template parameter,
701
- - a constant with literal type and is initialized with an expression
702
- that is value-dependent.
 
 
 
 
 
703
 
704
  Expressions of the following form are value-dependent if the
705
  *unary-expression* or *expression* is type-dependent or the *type-id* is
706
  dependent:
707
 
@@ -711,12 +726,13 @@ Expressions of the following form are value-dependent if either the
711
  *type-id* or *simple-type-specifier* is dependent or the *expression* or
712
  *cast-expression* is value-dependent:
713
 
714
  Expressions of the following form are value-dependent:
715
 
716
- An *id-expression* is value-dependent if it names a member of an unknown
717
- specialization.
 
718
 
719
  #### Dependent template arguments <a id="temp.dep.temp">[[temp.dep.temp]]</a>
720
 
721
  A type *template-argument* is dependent if the type it specifies is
722
  dependent.
@@ -784,10 +800,21 @@ If a function template or member function of a class template is called
784
  in a way which uses the definition of a default argument of that
785
  function template or member function, the point of instantiation of the
786
  default argument is the point of instantiation of the function template
787
  or member function specialization.
788
 
 
 
 
 
 
 
 
 
 
 
 
789
  For a class template specialization, a class member template
790
  specialization, or a specialization for a class member of a class
791
  template, if the specialization is implicitly instantiated because it is
792
  referenced from within another template specialization, if the context
793
  from which the specialization is referenced depends on a template
@@ -824,31 +851,28 @@ units. If two different points of instantiation give a template
824
  specialization different meanings according to the one definition rule (
825
  [[basic.def.odr]]), the program is ill-formed, no diagnostic required.
826
 
827
  #### Candidate functions <a id="temp.dep.candidate">[[temp.dep.candidate]]</a>
828
 
829
- For a function call that depends on a template parameter, the candidate
830
- functions are found using the usual lookup rules (
831
- [[basic.lookup.unqual]], [[basic.lookup.argdep]],  
832
- [[basic.lookup.qual]]) except that:
833
 
834
  - For the part of the lookup using unqualified name lookup (
835
- [[basic.lookup.unqual]]) or qualified name lookup (
836
- [[basic.lookup.qual]]), only function declarations from the template
837
  definition context are found.
838
  - For the part of the lookup using associated namespaces (
839
  [[basic.lookup.argdep]]), only function declarations found in either
840
  the template definition context or the template instantiation context
841
  are found.
842
 
843
- If the function name is an *unqualified-id* and the call would be
844
- ill-formed or would find a better match had the lookup within the
845
- associated namespaces considered all the function declarations with
846
- external linkage introduced in those namespaces in all translation
847
- units, not just considering those declarations found in the template
848
- definition and template instantiation contexts, then the program has
849
- undefined behavior.
850
 
851
  ### Friend names declared within a class template <a id="temp.inject">[[temp.inject]]</a>
852
 
853
  Friend classes or functions can be declared within a class template.
854
  When a template is instantiated, the names of its friends are treated as
 
126
  B b; // OK, no typename required
127
  };
128
  ```
129
 
130
  Knowing which names are type names allows the syntax of every template
131
+ to be checked. No diagnostic shall be issued for a template for which a
132
+ valid specialization can be generated. If no valid specialization can be
133
+ generated for a template, and that template is not instantiated, the
134
+ template is ill-formed, no diagnostic required. If every valid
135
+ specialization of a variadic template requires an empty template
136
+ parameter pack, the template is ill-formed, no diagnostic required. If a
137
+ type used in a non-dependent name is incomplete at the point at which a
 
138
  template is defined but is complete at the point at which an
139
  instantiation is done, and if the completeness of that type affects
140
  whether or not the program is well-formed or affects the semantics of
141
  the program, the program is ill-formed; no diagnostic is required. If a
142
  template is instantiated, errors will be diagnosed according to the
 
227
  // by two calls of f(E)
228
  g('a'); // will cause three calls of f(char)
229
  }
230
  ```
231
 
232
+ For purposes of name lookup, default arguments and
233
+ *exception-specification*s of function templates and default arguments
234
+ and *exception-specification*s of member functions of class templates
235
+ are considered definitions ([[temp.decls]]).
236
 
237
  ### Locally declared names <a id="temp.local">[[temp.local]]</a>
238
 
239
  Like normal (non-template) classes, class templates have an
240
  injected-class-name (Clause  [[class]]). The injected-class-name can be
 
396
  arguments) and this determines the context for name lookup for certain
397
  names. Expressions may be *type-dependent* (on the type of a template
398
  parameter) or *value-dependent* (on the value of a non-type template
399
  parameter). In an expression of the form:
400
 
401
+ where the *postfix-expression* is an *unqualified-id*, the
402
+ *unqualified-id* denotes a *dependent name* if
403
 
404
  - any of the expressions in the *expression-list* is a pack expansion (
405
  [[temp.variadic]]),
406
  - any of the expressions in the *expression-list* is a type-dependent
407
  expression ([[temp.dep.expr]]), or
408
+ - if the *unqualified-id* is a *template-id* in which any of the
409
+ template arguments depends on a template parameter.
410
 
411
  If an operand of an operator is a type-dependent expression, the
412
  operator also denotes a dependent name. Such names are unbound and are
413
  looked up at the point of the template instantiation ([[temp.point]])
414
  in both the context of the template definition and the context of the
 
540
  ```
541
 
542
  A name is a *member of the current instantiation* if it is
543
 
544
  - An unqualified name that, when looked up, refers to at least one
545
+ member of a class that is the current instantiation or a non-dependent
546
+ base class thereof. This can only occur when looking up a name in a
547
+ scope enclosed by the definition of a class template.
548
  - A *qualified-id* in which the *nested-name-specifier* refers to the
549
  current instantiation and that, when looked up, refers to at least one
550
+ member of a class that is the current instantiation or a non-dependent
551
+ base class thereof. if no such member is found, and the current
552
+ instantiation has any dependent base classes, then the *qualified-id*
553
+ is a member of an unknown specialization; see below.
554
  - An *id-expression* denoting the member in a class member access
555
  expression ([[expr.ref]]) for which the type of the object expression
556
  is the current instantiation, and the *id-expression*, when looked
557
+ up ([[basic.lookup.classref]]), refers to at least one member of a
558
+ class that is the current instantiation or a non-dependent base class
559
+ thereof. if no such member is found, and the current instantiation has
560
+ any dependent base classes, then the *id-expression* is a member of an
561
+ unknown specialization; see below.
562
 
563
  ``` cpp
564
  template <class T> class A {
565
  static const int i = 5;
566
  int n1[i]; // i refers to a member of the current instantiation
 
572
  template <class T> int A<T>::f() {
573
  return i; // i refers to a member of the current instantiation
574
  }
575
  ```
576
 
577
+ A name is a *dependent member of the current instantiation* if it is a
578
+ member of the current instantiation that, when looked up, refers to at
579
+ least one member of a class that is the current instantiation.
580
+
581
  A name is a *member of an unknown specialization* if it is
582
 
583
  - A *qualified-id* in which the *nested-name-specifier* names a
584
  dependent type that is not the current instantiation.
585
  - A *qualified-id* in which the *nested-name-specifier* refers to the
586
  current instantiation, the current instantiation has at least one
587
  dependent base class, and name lookup of the *qualified-id* does not
588
+ find any member of a class that is the current instantiation or a
589
+ non-dependent base class thereof.
590
  - An *id-expression* denoting the member in a class member access
591
  expression ([[expr.ref]]) in which either
592
  - the type of the object expression is the current instantiation, the
593
  current instantiation has at least one dependent base class, and
594
+ name lookup of the *id-expression* does not find a member of a class
595
+ that is the current instantiation or a non-dependent base class
596
+ thereof; or
597
  - the type of the object expression is dependent and is not the
598
  current instantiation.
599
 
600
  If a *qualified-id* in which the *nested-name-specifier* refers to the
601
  current instantiation is not a member of the current instantiation or a
 
633
 
634
  A type is dependent if it is
635
 
636
  - a template parameter,
637
  - a member of an unknown specialization,
638
+ - a nested class or enumeration that is a dependent member of the
639
+ current instantiation,
640
  - a cv-qualified type where the cv-unqualified type is dependent,
641
  - a compound type constructed from any dependent type,
642
  - an array type constructed from any dependent type or whose size is
643
  specified by a constant expression that is value-dependent,
644
  - a *simple-template-id* in which either the template name is a template
 
664
 
665
  An *id-expression* is type-dependent if it contains
666
 
667
  - an *identifier* associated by name lookup with one or more
668
  declarations declared with a dependent type,
669
+ - an *identifier* associated by name lookup with one or more
670
+ declarations of member functions of the current instantiation declared
671
+ with a return type that contains a placeholder type (
672
+ [[dcl.spec.auto]]),
673
  - a *template-id* that is dependent,
674
  - a *conversion-function-id* that specifies a dependent type, or
675
  - a *nested-name-specifier* or a *qualified-id* that names a member of
676
  an unknown specialization;
677
 
678
+ or if it names a dependent member of the current instantiation that is a
679
+ static data member of type “array of unknown bound of `T`” for some
680
+ `T` ([[temp.static]]). Expressions of the following forms are
681
+ type-dependent only if the type specified by the *type-id*,
682
+ *simple-type-specifier* or *new-type-id* is dependent, even if any
683
+ subexpression is type-dependent:
684
 
685
  Expressions of the following forms are never type-dependent (because the
686
  type of the expression cannot be dependent):
687
 
688
  For the standard library macro `offsetof`, see  [[support.types]].
 
702
  #### Value-dependent expressions <a id="temp.dep.constexpr">[[temp.dep.constexpr]]</a>
703
 
704
  Except as described below, a constant expression is value-dependent if
705
  any subexpression is value-dependent.
706
 
707
+ An *id-expression* is value-dependent if:
708
 
709
+ - it is a name declared with a dependent type,
710
+ - it is the name of a non-type template parameter,
711
+ - it names a member of an unknown specialization,
712
+ - it names a static data member that is a dependent member of the
713
+ current instantiation and is not initialized in a *member-declarator*,
714
+ - it names a static member function that is a dependent member of the
715
+ current instantiation, or
716
+ - it is a constant with literal type and is initialized with an
717
+ expression that is value-dependent.
718
 
719
  Expressions of the following form are value-dependent if the
720
  *unary-expression* or *expression* is type-dependent or the *type-id* is
721
  dependent:
722
 
 
726
  *type-id* or *simple-type-specifier* is dependent or the *expression* or
727
  *cast-expression* is value-dependent:
728
 
729
  Expressions of the following form are value-dependent:
730
 
731
+ An expression of the form `&`*qualified-id* where the *qualified-id*
732
+ names a dependent member of the current instantiation is
733
+ value-dependent.
734
 
735
  #### Dependent template arguments <a id="temp.dep.temp">[[temp.dep.temp]]</a>
736
 
737
  A type *template-argument* is dependent if the type it specifies is
738
  dependent.
 
800
  in a way which uses the definition of a default argument of that
801
  function template or member function, the point of instantiation of the
802
  default argument is the point of instantiation of the function template
803
  or member function specialization.
804
 
805
+ For an *exception-specification* of a function template specialization
806
+ or specialization of a member function of a class template, if the
807
+ *exception-specification* is implicitly instantiated because it is
808
+ needed by another template specialization and the context that requires
809
+ it depends on a template parameter, the point of instantiation of the
810
+ *exception-specification* is the point of instantiation of the
811
+ specialization that requires it. Otherwise, the point of instantiation
812
+ for such an *exception-specification* immediately follows the namespace
813
+ scope declaration or definition that requires the
814
+ *exception-specification*.
815
+
816
  For a class template specialization, a class member template
817
  specialization, or a specialization for a class member of a class
818
  template, if the specialization is implicitly instantiated because it is
819
  referenced from within another template specialization, if the context
820
  from which the specialization is referenced depends on a template
 
851
  specialization different meanings according to the one definition rule (
852
  [[basic.def.odr]]), the program is ill-formed, no diagnostic required.
853
 
854
  #### Candidate functions <a id="temp.dep.candidate">[[temp.dep.candidate]]</a>
855
 
856
+ For a function call where the *postfix-expression* is a dependent name,
857
+ the candidate functions are found using the usual lookup rules (
858
+ [[basic.lookup.unqual]], [[basic.lookup.argdep]]) except that:
 
859
 
860
  - For the part of the lookup using unqualified name lookup (
861
+ [[basic.lookup.unqual]]), only function declarations from the template
 
862
  definition context are found.
863
  - For the part of the lookup using associated namespaces (
864
  [[basic.lookup.argdep]]), only function declarations found in either
865
  the template definition context or the template instantiation context
866
  are found.
867
 
868
+ If the call would be ill-formed or would find a better match had the
869
+ lookup within the associated namespaces considered all the function
870
+ declarations with external linkage introduced in those namespaces in all
871
+ translation units, not just considering those declarations found in the
872
+ template definition and template instantiation contexts, then the
873
+ program has undefined behavior.
 
874
 
875
  ### Friend names declared within a class template <a id="temp.inject">[[temp.inject]]</a>
876
 
877
  Friend classes or functions can be declared within a class template.
878
  When a template is instantiated, the names of its friends are treated as