From Jason Turner

[func.bind]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptf5xwyvr/{from.md → to.md} +66 -84
tmp/tmptf5xwyvr/{from.md → to.md} RENAMED
@@ -13,18 +13,18 @@ namespace std {
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 {
@@ -34,120 +34,100 @@ namespace std {
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 {
@@ -159,23 +139,25 @@ namespace std::placeholders {
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
 
 
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
+ Specializations of the `is_bind_expression` template shall meet the
19
+ *Cpp17UnaryTypeTrait* requirements [[meta.rqmts]]. The implementation
20
+ provides a definition that has a base characteristic of `true_type` if
21
+ `T` is a type returned from `bind`, otherwise it has a base
22
  characteristic of `false_type`. A program may specialize this template
23
+ for a program-defined type `T` to have a base characteristic of
24
+ `true_type` to indicate that `T` should be treated as a subexpression in
25
+ a `bind` call.
26
 
27
  #### Class template `is_placeholder` <a id="func.bind.isplace">[[func.bind.isplace]]</a>
28
 
29
  ``` cpp
30
  namespace std {
 
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
+ Specializations of the `is_placeholder` template shall meet the
40
+ *Cpp17UnaryTypeTrait* requirements [[meta.rqmts]]. The implementation
41
+ provides 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 has a base characteristic of
44
+ `integral_constant<int, 0>`. A program may specialize this template for
45
+ a program-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
+ - `g` is a value of the result of a `bind` invocation,
54
  - `FD` is the type `decay_t<F>`,
55
+ - `fd` is an lvalue that is a target object of `g` [[func.def]] of type
56
+ `FD` direct-non-list-initialized with `std::forward<F>(f)`,
57
  - `Tᵢ` is the iᵗʰ type in the template parameter pack `BoundArgs`,
58
  - `TDᵢ` is the type `decay_t<Tᵢ>`,
59
  - `tᵢ` is the iᵗʰ argument in the function parameter pack `bound_args`,
60
+ - `tdᵢ` is a bound argument entity of `g` [[func.def]] of type `TDᵢ`
61
+ direct-non-list-initialized with `std::forward<{}Tᵢ>(tᵢ)`,
62
  - `Uⱼ` is the jᵗʰ deduced type of the `UnBoundArgs&&...` parameter of
63
+ the argument forwarding call wrapper, and
64
  - `uⱼ` is the jᵗʰ argument associated with `Uⱼ`.
65
 
66
  ``` cpp
67
  template<class F, class... BoundArgs>
68
+ constexpr unspecified bind(F&& f, BoundArgs&&... bound_args);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  template<class R, class F, class... BoundArgs>
70
+ constexpr unspecified bind(F&& f, BoundArgs&&... bound_args);
71
  ```
72
 
73
+ *Mandates:* `is_constructible_v<FD, F>` is `true`. For each `Tᵢ` in
74
+ `BoundArgs`, `is_constructible_v<``TDᵢ``, ``Tᵢ``>` is `true`.
 
 
 
 
75
 
76
+ *Preconditions:* `FD` and each `TDᵢ` meet the *Cpp17MoveConstructible*
77
+ and *Cpp17Destructible* requirements. *INVOKE*(fd, w₁, w₂, …,
78
+ $w_N$) [[func.require]] is a valid expression for some values `w₁`,
79
+ `w₂`, …, `w_N`, where N has the value `sizeof...(bound_args)`.
80
+
81
+ *Returns:* An argument forwarding call wrapper `g` [[func.require]]. A
82
+ program that attempts to invoke a volatile-qualified `g` is ill-formed.
83
+ When `g` is not volatile-qualified, invocation of
84
+ `g(``u₁``, ``u₂``, `…`, ``u_M``)` is
85
+ expression-equivalent [[defns.expression-equivalent]] to
86
 
87
  ``` cpp
88
+ INVOKE(static_cast<$V_fd$>($v_fd$),
89
+ static_cast<$V_1$>($v_1$), static_cast<$V_2$>($v_2$), …, static_cast<$V_N$>($v_N$))
90
  ```
91
 
92
+ for the first overload, and
93
+
94
+ ``` cpp
95
+ INVOKE<R>(static_cast<$V_fd$>($v_fd$),
96
+ static_cast<$V_1$>($v_1$), static_cast<$V_2$>($v_2$), …, static_cast<$V_N$>($v_N$))
97
+ ```
98
 
99
+ for the second overload, where the values and types of the target
100
+ argument `v`_`fd` and of the bound arguments `v₁`, `v₂`, …, `v_N` are
101
+ determined as specified below.
102
 
103
+ *Throws:* Any exception thrown by the initialization of the state
104
+ entities of `g`.
 
 
105
 
106
+ [*Note 1*: If all of `FD` and `TDᵢ` meet the requirements of
107
+ *Cpp17CopyConstructible*, then the return type meets the requirements of
108
+ *Cpp17CopyConstructible*. — *end note*]
109
 
110
  The values of the *bound arguments* `v₁`, `v₂`, …, `v_N` and their
111
  corresponding types `V₁`, `V₂`, …, `V_N` depend on the types `TDᵢ`
112
  derived from the call to `bind` and the cv-qualifiers cv of the call
113
  wrapper `g` as follows:
114
 
115
  - if `TDᵢ` is `reference_wrapper<T>`, the argument is `tdᵢ.get()` and
116
  its type `Vᵢ` is `T&`;
117
  - if the value of `is_bind_expression_v<TDᵢ>` is `true`, the argument is
118
+ ``` cpp
119
+ static_cast<cv `TD`_i&>(td_i)(std::forward<U_j>(u_j)...)
120
+ ```
121
+
122
+ and its type `Vᵢ` is `invoke_result_t<cv TDᵢ&, Uⱼ...>&&`;
123
  - if the value `j` of `is_placeholder_v<TDᵢ>` is not zero, the argument
124
  is `std::forward<Uⱼ>(uⱼ)` and its type `Vᵢ` is `Uⱼ&&`;
125
+ - otherwise, the value is `tdᵢ` and its type `Vᵢ` is `cv TDᵢ&`.
126
+
127
+ The value of the target argument `v`_`fd` is `fd` and its corresponding
128
+ type `V`_`fd` is `cv FD&`.
129
 
130
  #### Placeholders <a id="func.bind.place">[[func.bind.place]]</a>
131
 
132
  ``` cpp
133
  namespace std::placeholders {
 
139
  .
140
  see below _M;
141
  }
142
  ```
143
 
144
+ All placeholder types meet the *Cpp17DefaultConstructible* and
145
+ *Cpp17CopyConstructible* requirements, and their default constructors
146
+ and copy/move constructors are constexpr functions that do not throw
147
+ exceptions. It is *implementation-defined* whether placeholder types
148
+ meet the *Cpp17CopyAssignable* requirements, but if so, their copy
149
+ assignment operators are constexpr functions that do not throw
150
+ exceptions.
151
 
152
  Placeholders should be defined as:
153
 
154
  ``` cpp
155
  inline constexpr unspecified _1{};
156
  ```
157
 
158
+ If they are not, they are declared as:
159
 
160
  ``` cpp
161
  extern unspecified _1;
162
  ```
163