From Jason Turner

[temp.mem]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpz83hvg49/{from.md → to.md} +37 -20
tmp/tmpz83hvg49/{from.md → to.md} RENAMED
@@ -2,13 +2,13 @@
2
 
3
  A template can be declared within a class or class template; such a
4
  template is called a member template. A member template can be defined
5
  within or outside its class definition or class template definition. A
6
  member template of a class template that is defined outside of its class
7
- template definition shall be specified with the *template-parameter*s of
8
- the class template followed by the *template-parameter*s of the member
9
- template.
10
 
11
  [*Example 1*:
12
 
13
  ``` cpp
14
  template<class T> struct string {
@@ -20,20 +20,39 @@ template<class T> template<class T2> int string<T>::compare(const T2& s) {
20
  }
21
  ```
22
 
23
  — *end example*]
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  A local class of non-closure type shall not have member templates.
26
- Access control rules (Clause  [[class.access]]) apply to member template
27
- names. A destructor shall not be a member template. A non-template
28
- member function ([[dcl.fct]]) with a given name and type and a member
29
- function template of the same name, which could be used to generate a
30
  specialization of the same type, can both be declared in a class. When
31
  both exist, a use of that name and type refers to the non-template
32
  member unless an explicit template argument list is supplied.
33
 
34
- [*Example 2*:
35
 
36
  ``` cpp
37
  template <class T> struct A {
38
  void f(int);
39
  template <class T2> void f(T2);
@@ -52,11 +71,11 @@ int main() {
52
 
53
  — *end example*]
54
 
55
  A member function template shall not be virtual.
56
 
57
- [*Example 3*:
58
 
59
  ``` cpp
60
  template <class T> struct AA {
61
  template <class C> virtual void g(C); // error
62
  virtual void f(); // OK
@@ -66,11 +85,11 @@ template <class T> struct AA {
66
  — *end example*]
67
 
68
  A specialization of a member function template does not override a
69
  virtual function from a base class.
70
 
71
- [*Example 4*:
72
 
73
  ``` cpp
74
  class B {
75
  virtual void f(int);
76
  };
@@ -85,11 +104,11 @@ class D : public B {
85
 
86
  A specialization of a conversion function template is referenced in the
87
  same way as a non-template conversion function that converts to the same
88
  type.
89
 
90
- [*Example 5*:
91
 
92
  ``` cpp
93
  struct A {
94
  template <class T> operator T*();
95
  };
@@ -104,25 +123,23 @@ int main() {
104
  }
105
  ```
106
 
107
  — *end example*]
108
 
109
- [*Note 1*: Because the explicit template argument list follows the
110
- function template name, and because conversion member function templates
111
- and constructor member function templates are called without using a
112
- function name, there is no way to provide an explicit template argument
113
- list for these function templates. — *end note*]
114
 
115
  A specialization of a conversion function template is not found by name
116
  lookup. Instead, any conversion function templates visible in the
117
  context of the use are considered. For each such operator, if argument
118
- deduction succeeds ([[temp.deduct.conv]]), the resulting specialization
119
- is used as if found by name lookup.
120
 
121
  A *using-declaration* in a derived class cannot refer to a
122
  specialization of a conversion function template in a base class.
123
 
124
- Overload resolution ([[over.ics.rank]]) and partial ordering (
125
- [[temp.func.order]]) are used to select the best conversion function
126
  among multiple specializations of conversion function templates and/or
127
  non-template conversion functions.
128
 
 
2
 
3
  A template can be declared within a class or class template; such a
4
  template is called a member template. A member template can be defined
5
  within or outside its class definition or class template definition. A
6
  member template of a class template that is defined outside of its class
7
+ template definition shall be specified with a *template-head* equivalent
8
+ to that of the class template followed by a *template-head* equivalent
9
+ to that of the member template [[temp.over.link]].
10
 
11
  [*Example 1*:
12
 
13
  ``` cpp
14
  template<class T> struct string {
 
20
  }
21
  ```
22
 
23
  — *end example*]
24
 
25
+ [*Example 2*:
26
+
27
+ ``` cpp
28
+ template<typename T> concept C1 = true;
29
+ template<typename T> concept C2 = sizeof(T) <= 4;
30
+
31
+ template<C1 T> struct S {
32
+ template<C2 U> void f(U);
33
+ template<C2 U> void g(U);
34
+ };
35
+
36
+ template<C1 T> template<C2 U>
37
+ void S<T>::f(U) { } // OK
38
+ template<C1 T> template<typename U>
39
+ void S<T>::g(U) { } // error: no matching function in S<T>
40
+ ```
41
+
42
+ — *end example*]
43
+
44
  A local class of non-closure type shall not have member templates.
45
+ Access control rules [[class.access]] apply to member template names. A
46
+ destructor shall not be a member template. A non-template member
47
+ function [[dcl.fct]] with a given name and type and a member function
48
+ template of the same name, which could be used to generate a
49
  specialization of the same type, can both be declared in a class. When
50
  both exist, a use of that name and type refers to the non-template
51
  member unless an explicit template argument list is supplied.
52
 
53
+ [*Example 3*:
54
 
55
  ``` cpp
56
  template <class T> struct A {
57
  void f(int);
58
  template <class T2> void f(T2);
 
71
 
72
  — *end example*]
73
 
74
  A member function template shall not be virtual.
75
 
76
+ [*Example 4*:
77
 
78
  ``` cpp
79
  template <class T> struct AA {
80
  template <class C> virtual void g(C); // error
81
  virtual void f(); // OK
 
85
  — *end example*]
86
 
87
  A specialization of a member function template does not override a
88
  virtual function from a base class.
89
 
90
+ [*Example 5*:
91
 
92
  ``` cpp
93
  class B {
94
  virtual void f(int);
95
  };
 
104
 
105
  A specialization of a conversion function template is referenced in the
106
  same way as a non-template conversion function that converts to the same
107
  type.
108
 
109
+ [*Example 6*:
110
 
111
  ``` cpp
112
  struct A {
113
  template <class T> operator T*();
114
  };
 
123
  }
124
  ```
125
 
126
  — *end example*]
127
 
128
+ [*Note 1*: There is no syntax to form a *template-id* [[temp.names]] by
129
+ providing an explicit template argument list [[temp.arg.explicit]] for a
130
+ conversion function template [[class.conv.fct]]. *end note*]
 
 
131
 
132
  A specialization of a conversion function template is not found by name
133
  lookup. Instead, any conversion function templates visible in the
134
  context of the use are considered. For each such operator, if argument
135
+ deduction succeeds [[temp.deduct.conv]], the resulting specialization is
136
+ used as if found by name lookup.
137
 
138
  A *using-declaration* in a derived class cannot refer to a
139
  specialization of a conversion function template in a base class.
140
 
141
+ Overload resolution [[over.ics.rank]] and partial ordering
142
+ [[temp.func.order]] are used to select the best conversion function
143
  among multiple specializations of conversion function templates and/or
144
  non-template conversion functions.
145