From Jason Turner

[temp.fct]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpzarsodkz/{from.md → to.md} +23 -11
tmp/tmpzarsodkz/{from.md → to.md} RENAMED
@@ -7,12 +7,12 @@ family of sort functions might be declared like this:
7
  template<class T> class Array { };
8
  template<class T> void sort(Array<T>&);
9
  ```
10
 
11
  A function template can be overloaded with other function templates and
12
- with normal (non-template) functions. A normal function is not related
13
- to a function template (i.e., it is never considered to be a
14
  specialization), even if it has the same name and type as a potentially
15
  generated function template specialization.[^5]
16
 
17
  #### Function template overloading <a id="temp.over.link">[[temp.over.link]]</a>
18
 
@@ -77,15 +77,26 @@ Two expressions involving template parameters are considered
77
  *equivalent* if two function definitions containing the expressions
78
  would satisfy the one definition rule ([[basic.def.odr]]), except that
79
  the tokens used to name the template parameters may differ as long as a
80
  token used to name a template parameter in one expression is replaced by
81
  another token that names the same template parameter in the other
82
- expression.
 
 
 
 
83
 
84
  ``` cpp
85
  template <int I, int J> void f(A<I+J>); // #1
86
  template <int K, int L> void f(A<K+L>); // same as #1
 
 
 
 
 
 
 
87
  ```
88
 
89
  Two expressions involving template parameters that are not equivalent
90
  are *functionally equivalent* if, for any given set of template
91
  arguments, the evaluation of the expression results in the same value.
@@ -152,18 +163,19 @@ specialized template is the one chosen by the partial ordering process.
152
  To produce the transformed template, for each type, non-type, or
153
  template template parameter (including template parameter packs (
154
  [[temp.variadic]]) thereof) synthesize a unique type, value, or class
155
  template respectively and substitute it for each occurrence of that
156
  parameter in the function type of the template. If only one of the
157
- function templates is a non-static member, that function template is
158
- considered to have a new first parameter inserted in its function
159
- parameter list. The new parameter is of type “reference to cv `A`,”
160
- where cv are the cv-qualifiers of the function template (if any) and `A`
161
- is the class of which the function template is a member. This allows a
162
- non-static member to be ordered with respect to a nonmember function and
163
- for the results to be equivalent to the ordering of two equivalent
164
- nonmembers.
 
165
 
166
  ``` cpp
167
  struct A { };
168
  template<class T> struct B {
169
  template<class R> int operator*(R&); // #1
 
7
  template<class T> class Array { };
8
  template<class T> void sort(Array<T>&);
9
  ```
10
 
11
  A function template can be overloaded with other function templates and
12
+ with non-template functions ([[dcl.fct]]). A non-template function is
13
+ not related to a function template (i.e., it is never considered to be a
14
  specialization), even if it has the same name and type as a potentially
15
  generated function template specialization.[^5]
16
 
17
  #### Function template overloading <a id="temp.over.link">[[temp.over.link]]</a>
18
 
 
77
  *equivalent* if two function definitions containing the expressions
78
  would satisfy the one definition rule ([[basic.def.odr]]), except that
79
  the tokens used to name the template parameters may differ as long as a
80
  token used to name a template parameter in one expression is replaced by
81
  another token that names the same template parameter in the other
82
+ expression. For determining whether two dependent names ([[temp.dep]])
83
+ are equivalent, only the name itself is considered, not the result of
84
+ name lookup in the context of the template. If multiple declarations of
85
+ the same function template differ in the result of this name lookup, the
86
+ result for the first declaration is used.
87
 
88
  ``` cpp
89
  template <int I, int J> void f(A<I+J>); // #1
90
  template <int K, int L> void f(A<K+L>); // same as #1
91
+
92
+ template <class T> decltype(g(T())) h();
93
+ int g(int);
94
+ template <class T> decltype(g(T())) h() // redeclaration of h() uses the earlier lookup
95
+ { return g(T()); } // ...although the lookup here does find g(int)
96
+ int i = h<int>(); // template argument substitution fails; g(int)
97
+ // was not in scope at the first declaration of h()
98
  ```
99
 
100
  Two expressions involving template parameters that are not equivalent
101
  are *functionally equivalent* if, for any given set of template
102
  arguments, the evaluation of the expression results in the same value.
 
163
  To produce the transformed template, for each type, non-type, or
164
  template template parameter (including template parameter packs (
165
  [[temp.variadic]]) thereof) synthesize a unique type, value, or class
166
  template respectively and substitute it for each occurrence of that
167
  parameter in the function type of the template. If only one of the
168
+ function templates is a non-static member of some class `A`, that
169
+ function template is considered to have a new first parameter inserted
170
+ in its function parameter list. Given cv as the cv-qualifiers of the
171
+ function template (if any), the new parameter is of type “rvalue
172
+ reference to cv `A`” if the optional *ref-qualifier* of the function
173
+ template is `&&`, or of type “lvalue reference to cv `A`” otherwise.
174
+ This allows a non-static member to be ordered with respect to a
175
+ nonmember function and for the results to be equivalent to the ordering
176
+ of two equivalent nonmembers.
177
 
178
  ``` cpp
179
  struct A { };
180
  template<class T> struct B {
181
  template<class R> int operator*(R&); // #1