From Jason Turner

[func.bind]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmprz7c8qo7/{from.md → to.md} +102 -78
tmp/tmprz7c8qo7/{from.md → to.md} RENAMED
@@ -9,149 +9,173 @@ callable objects.
9
  namespace std {
10
  template<class T> struct is_bind_expression; // see below
11
  }
12
  ```
13
 
14
- `is_bind_expression` can be used to detect function objects generated by
15
- `bind`. `bind` uses `is_bind_expression` to detect subexpressions.
 
16
 
17
  Instantiations of the `is_bind_expression` template shall meet the
18
- UnaryTypeTrait requirements ([[meta.rqmts]]). The implementation shall
19
- provide a definition that has a BaseCharacteristic of `true_type` if `T`
20
- is a type returned from `bind`, otherwise it shall have a
21
- BaseCharacteristic of `false_type`. A program may specialize this
22
- template for a user-defined type `T` to have a BaseCharacteristic of
23
- `true_type` to indicate that `T` should be treated as a subexpression in
24
- a `bind` call.
25
 
26
  #### Class template `is_placeholder` <a id="func.bind.isplace">[[func.bind.isplace]]</a>
27
 
28
  ``` cpp
29
  namespace std {
30
  template<class T> struct is_placeholder; // see below
31
  }
32
  ```
33
 
34
- `is_placeholder` can be used to detect the standard placeholders `_1`,
35
- `_2`, and so on. `bind` uses `is_placeholder` to detect placeholders.
 
36
 
37
  Instantiations of the `is_placeholder` template shall meet the
38
- UnaryTypeTrait requirements ([[meta.rqmts]]). The implementation shall
39
- provide a definition that has the BaseCharacteristic of
40
  `integral_constant<int, J>` if `T` is the type of
41
- `std::placeholders::_J`, otherwise it shall have a BaseCharacteristic of
42
- `integral_constant<int, 0>`. A program may specialize this template for
43
- a user-defined type `T` to have a BaseCharacteristic of
44
  `integral_constant<int, N>` with `N > 0` to indicate that `T` should be
45
  treated as a placeholder type.
46
 
47
  #### Function template `bind` <a id="func.bind.bind">[[func.bind.bind]]</a>
48
 
49
- In the text that follows, the following names have the following
50
- meanings:
51
 
52
  - `FD` is the type `decay_t<F>`,
53
  - `fd` is an lvalue of type `FD` constructed from `std::forward<F>(f)`,
54
- - `Ti` is the iᵗʰ type in the template parameter pack `BoundArgs`,
55
- - `TiD` is the type `decay_t<Ti>`,
56
- - `ti` is the iᵗʰ argument in the function parameter pack `bound_args`,
57
- - `tid` is an lvalue of type `TiD` constructed from
58
- `std::forward<Ti>(ti)`,
59
- - `Uj` is the jᵗʰ deduced type of the `UnBoundArgs&&...` parameter of
60
  the forwarding call wrapper, and
61
- - `uj` is the jᵗʰ argument associated with `Uj`.
62
 
63
  ``` cpp
64
  template<class F, class... BoundArgs>
65
  unspecified bind(F&& f, BoundArgs&&... bound_args);
66
  ```
67
 
68
- *Requires:* `is_constructible<FD, F>::value` shall be `true`. For each
69
- `Ti` in `BoundArgs`, `is_constructible<TiD, Ti>::value` shall be `true`.
70
- *`INVOKE`*` (fd, w1, w2, ..., wN)` ([[func.require]]) shall be a valid
71
- expression for some values *w1, w2, ..., wN*, where
72
- `N == sizeof...(bound_args)`.
 
73
 
74
- *Returns:* A forwarding call wrapper `g` with a weak result
75
- type ([[func.require]]). The effect of `g(u1, u2, ..., uM)` shall be
76
- *`INVOKE`*`(fd, std::forward<V1>(v1), std::forward<V2>(v2), ..., std::forward<VN>(vN), result_of_t<FD `*`cv`*` & (V1, V2, ..., VN)>)`,
77
- where *`cv`* represents the *cv*-qualifiers of `g` and the values and
78
- types of the bound arguments `v1, v2, ..., vN` are determined as
79
- specified below. The copy constructor and move constructor of the
80
- forwarding call wrapper shall throw an exception if and only if the
81
- corresponding constructor of `FD` or of any of the types `TiD` throws an
82
- exception.
 
 
 
83
 
84
  *Throws:* Nothing unless the construction of `fd` or of one of the
85
- values `tid` throws an exception.
86
 
87
  *Remarks:* The return type shall satisfy the requirements of
88
- `MoveConstructible`. If all of `FD` and `TiD` satisfy the requirements
89
  of `CopyConstructible`, then the return type shall satisfy the
90
- requirements of `CopyConstructible`. This implies that all of `FD` and
91
- `TiD` are `MoveConstructible`.
 
 
92
 
93
  ``` cpp
94
  template<class R, class F, class... BoundArgs>
95
  unspecified bind(F&& f, BoundArgs&&... bound_args);
96
  ```
97
 
98
- *Requires:* `is_constructible<FD, F>::value` shall be `true`. For each
99
- `Ti` in `BoundArgs`, `is_constructible<TiD, Ti>::value` shall be `true`.
100
- *`INVOKE`*`(fd, w1, w2, ..., wN)` shall be a valid expression for some
101
- values *w1, w2, ..., wN*, where `N == sizeof...(bound_args)`.
 
 
102
 
103
- *Returns:* A forwarding call wrapper `g` with a nested type
104
- `result_type` defined as a synonym for `R`. The effect of
105
- `g(u1, u2, ..., uM)` shall be
106
- *`INVOKE`*`(fd, std::forward<V1>(v1), std::forward<V2>(v2), ..., std::forward<VN>(vN), R)`,
107
- where the values and types of the bound arguments `v1, v2, ..., vN` are
108
- determined as specified below. The copy constructor and move constructor
109
- of the forwarding call wrapper shall throw an exception if and only if
110
- the corresponding constructor of `FD` or of any of the types `TiD`
111
- throws an exception.
 
 
 
112
 
113
  *Throws:* Nothing unless the construction of `fd` or of one of the
114
- values `tid` throws an exception.
115
 
116
  *Remarks:* The return type shall satisfy the requirements of
117
- `MoveConstructible`. If all of `FD` and `TiD` satisfy the requirements
118
  of `CopyConstructible`, then the return type shall satisfy the
119
- requirements of `CopyConstructible`. This implies that all of `FD` and
120
- `TiD` are `MoveConstructible`.
121
 
122
- The values of the *bound arguments* `v1, v2, ..., vN` and their
123
- corresponding types `V1, V2, ..., VN` depend on the types `TiD` derived
124
- from the call to `bind` and the *cv*-qualifiers *cv* of the call wrapper
125
- `g` as follows:
126
 
127
- - if `TiD` is `reference_wrapper<T>`, the argument is `tid.get()` and
128
- its type `Vi` is `T&`;
129
- - if the value of `is_bind_expression<TiD>::value` is `true`, the
130
- argument is `tid(std::forward<Uj>({}uj)...)` and its type `Vi` is
131
- `result_of_t<TiD cv & (Uj&&...)>&&`;
132
- - if the value `j` of `is_placeholder<TiD>::value` is not zero, the
133
- argument is `std::forward<Uj>(uj)` and its type `Vi` is `Uj&&`;
134
- - otherwise, the value is `tid` and its type `Vi` is `TiD cv &`.
 
 
 
 
 
135
 
136
  #### Placeholders <a id="func.bind.place">[[func.bind.place]]</a>
137
 
138
  ``` cpp
139
- namespace std {
140
- namespace placeholders {
141
  // M is the implementation-defined number of placeholders
142
- extern unspecified _1;
143
- extern unspecified _2;
144
  .
145
  .
146
  .
147
- extern unspecified _M;
148
- }
149
  }
150
  ```
151
 
152
  All placeholder types shall be `DefaultConstructible` and
153
  `CopyConstructible`, and their default constructors and copy/move
154
  constructors shall not throw exceptions. It is *implementation-defined*
155
  whether placeholder types are `CopyAssignable`. `CopyAssignable`
156
  placeholders’ copy assignment operators shall not throw exceptions.
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  namespace std {
10
  template<class T> struct is_bind_expression; // see below
11
  }
12
  ```
13
 
14
+ The class template `is_bind_expression` can be used to detect function
15
+ objects generated by `bind`. The function template `bind` uses
16
+ `is_bind_expression` to detect subexpressions.
17
 
18
  Instantiations of the `is_bind_expression` template shall meet the
19
+ `UnaryTypeTrait` requirements ([[meta.rqmts]]). The implementation
20
+ shall provide a definition that has a base characteristic of `true_type`
21
+ if `T` is a type returned from `bind`, otherwise it shall have a base
22
+ characteristic of `false_type`. A program may specialize this template
23
+ for a user-defined type `T` to have a base characteristic of `true_type`
24
+ to indicate that `T` should be treated as a subexpression in a `bind`
25
+ call.
26
 
27
  #### Class template `is_placeholder` <a id="func.bind.isplace">[[func.bind.isplace]]</a>
28
 
29
  ``` cpp
30
  namespace std {
31
  template<class T> struct is_placeholder; // see below
32
  }
33
  ```
34
 
35
+ The class template `is_placeholder` can be used to detect the standard
36
+ placeholders `_1`, `_2`, and so on. The function template `bind` uses
37
+ `is_placeholder` to detect placeholders.
38
 
39
  Instantiations of the `is_placeholder` template shall meet the
40
+ `UnaryTypeTrait` requirements ([[meta.rqmts]]). The implementation
41
+ shall provide a definition that has the base characteristic of
42
  `integral_constant<int, J>` if `T` is the type of
43
+ `std::placeholders::_J`, otherwise it shall have a base characteristic
44
+ of `integral_constant<int, 0>`. A program may specialize this template
45
+ for a user-defined type `T` to have a base characteristic of
46
  `integral_constant<int, N>` with `N > 0` to indicate that `T` should be
47
  treated as a placeholder type.
48
 
49
  #### Function template `bind` <a id="func.bind.bind">[[func.bind.bind]]</a>
50
 
51
+ In the text that follows:
 
52
 
53
  - `FD` is the type `decay_t<F>`,
54
  - `fd` is an lvalue of type `FD` constructed from `std::forward<F>(f)`,
55
+ - `Tᵢ` is the iᵗʰ type in the template parameter pack `BoundArgs`,
56
+ - `TDᵢ` is the type `decay_t<Tᵢ>`,
57
+ - `tᵢ` is the iᵗʰ argument in the function parameter pack `bound_args`,
58
+ - `tdᵢ` is an lvalue of type `TDᵢ` constructed from
59
+ `std::forward<Tᵢ>(tᵢ)`,
60
+ - `Uⱼ` is the jᵗʰ deduced type of the `UnBoundArgs&&...` parameter of
61
  the forwarding call wrapper, and
62
+ - `uⱼ` is the jᵗʰ argument associated with `Uⱼ`.
63
 
64
  ``` cpp
65
  template<class F, class... BoundArgs>
66
  unspecified bind(F&& f, BoundArgs&&... bound_args);
67
  ```
68
 
69
+ *Requires:* `is_constructible_v<FD, F>` shall be `true`. For each `Tᵢ`
70
+ in `BoundArgs`, `is_constructible_v<``TDᵢ``, ``Tᵢ``>` shall be `true`.
71
+ *INVOKE*(fd, w₁, w₂, , $w_N$) ([[func.require]]) shall be a valid
72
+ expression for some values `w₁`, `w₂`, , `w_N`, where N has the value
73
+ `sizeof...(bound_args)`. The cv-qualifiers cv of the call wrapper `g`,
74
+ as specified below, shall be neither `volatile` nor `const volatile`.
75
 
76
+ *Returns:* A forwarding call wrapper `g` ([[func.require]]). The effect
77
+ of `g(``u₁``, ``u₂``, , ``u_M``)` shall be
78
+
79
+ ``` cpp
80
+ INVOKE(fd, std::forward<$V_1$>($v_1$), std::forward<$V_2$>($v_2$), , std::forward<$V_N$>($v_N$))
81
+ ```
82
+
83
+ where the values and types of the bound arguments `v₁`, `v₂`, …, `v_N`
84
+ are determined as specified below. The copy constructor and move
85
+ constructor of the forwarding call wrapper shall throw an exception if
86
+ and only if the corresponding constructor of `FD` or of any of the types
87
+ `TDᵢ` throws an exception.
88
 
89
  *Throws:* Nothing unless the construction of `fd` or of one of the
90
+ values `tdᵢ` throws an exception.
91
 
92
  *Remarks:* The return type shall satisfy the requirements of
93
+ `MoveConstructible`. If all of `FD` and `TDᵢ` satisfy the requirements
94
  of `CopyConstructible`, then the return type shall satisfy the
95
+ requirements of `CopyConstructible`.
96
+
97
+ [*Note 1*: This implies that all of `FD` and `TDᵢ` are
98
+ `MoveConstructible`. — *end note*]
99
 
100
  ``` cpp
101
  template<class R, class F, class... BoundArgs>
102
  unspecified bind(F&& f, BoundArgs&&... bound_args);
103
  ```
104
 
105
+ *Requires:* `is_constructible_v<FD, F>` shall be `true`. For each `Tᵢ`
106
+ in `BoundArgs`, `is_constructible_v<``TDᵢ``, ``Tᵢ``>` shall be `true`.
107
+ *INVOKE*(fd, w₁, w₂, , $w_N$) shall be a valid expression for some
108
+ values `w₁`, `w₂`, , `w_N`, where N has the value
109
+ `sizeof...(bound_args)`. The cv-qualifiers cv of the call wrapper `g`,
110
+ as specified below, shall be neither `volatile` nor `const volatile`.
111
 
112
+ *Returns:* A forwarding call wrapper `g` ([[func.require]]). The effect
113
+ of `g(``u₁``, ``u₂``, …, ``u_M``)` shall be
114
+
115
+ ``` cpp
116
+ INVOKE<R>(fd, std::forward<$V_1$>($v_1$), std::forward<$V_2$>($v_2$), , std::forward<$V_N$>($v_N$))
117
+ ```
118
+
119
+ where the values and types of the bound arguments `v₁`, `v₂`, …, `v_N`
120
+ are determined as specified below. The copy constructor and move
121
+ constructor of the forwarding call wrapper shall throw an exception if
122
+ and only if the corresponding constructor of `FD` or of any of the types
123
+ `TDᵢ` throws an exception.
124
 
125
  *Throws:* Nothing unless the construction of `fd` or of one of the
126
+ values `tdᵢ` throws an exception.
127
 
128
  *Remarks:* The return type shall satisfy the requirements of
129
+ `MoveConstructible`. If all of `FD` and `TDᵢ` satisfy the requirements
130
  of `CopyConstructible`, then the return type shall satisfy the
131
+ requirements of `CopyConstructible`.
 
132
 
133
+ [*Note 2*: This implies that all of `FD` and `TDᵢ` are
134
+ `MoveConstructible`. *end note*]
 
 
135
 
136
+ The values of the *bound arguments* `v₁`, `v₂`, …, `v_N` and their
137
+ corresponding types `V₁`, `V₂`, …, `V_N` depend on the types `TDᵢ`
138
+ derived from the call to `bind` and the cv-qualifiers cv of the call
139
+ wrapper `g` as follows:
140
+
141
+ - if `TDᵢ` is `reference_wrapper<T>`, the argument is `tdᵢ.get()` and
142
+ its type `Vᵢ` is `T&`;
143
+ - if the value of `is_bind_expression_v<TDᵢ>` is `true`, the argument is
144
+ `tdᵢ(std::forward<Uⱼ>(uⱼ)...)` and its type `Vᵢ` is
145
+ `invoke_result_t<TDᵢ cv &, Uⱼ...>&&`;
146
+ - if the value `j` of `is_placeholder_v<TDᵢ>` is not zero, the argument
147
+ is `std::forward<Uⱼ>(uⱼ)` and its type `Vᵢ` is `Uⱼ&&`;
148
+ - otherwise, the value is `tdᵢ` and its type `Vᵢ` is `TDᵢ cv &`.
149
 
150
  #### Placeholders <a id="func.bind.place">[[func.bind.place]]</a>
151
 
152
  ``` cpp
153
+ namespace std::placeholders {
 
154
  // M is the implementation-defined number of placeholders
155
+ see below _1;
156
+ see below _2;
157
  .
158
  .
159
  .
160
+ see below _M;
 
161
  }
162
  ```
163
 
164
  All placeholder types shall be `DefaultConstructible` and
165
  `CopyConstructible`, and their default constructors and copy/move
166
  constructors shall not throw exceptions. It is *implementation-defined*
167
  whether placeholder types are `CopyAssignable`. `CopyAssignable`
168
  placeholders’ copy assignment operators shall not throw exceptions.
169
 
170
+ Placeholders should be defined as:
171
+
172
+ ``` cpp
173
+ inline constexpr unspecified _1{};
174
+ ```
175
+
176
+ If they are not, they shall be declared as:
177
+
178
+ ``` cpp
179
+ extern unspecified _1;
180
+ ```
181
+