From Jason Turner

[func.wrap]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp3q8zyauu/{from.md → to.md} +102 -102
tmp/tmp3q8zyauu/{from.md → to.md} RENAMED
@@ -9,84 +9,75 @@ An exception of type `bad_function_call` is thrown by
9
  `function::operator()` ([[func.wrap.func.inv]]) when the function
10
  wrapper object has no target.
11
 
12
  ``` cpp
13
  namespace std {
14
- class bad_function_call : public std::exception {
15
  public:
16
- // [func.wrap.badcall.const], constructor:
17
  bad_function_call() noexcept;
18
  };
19
- } // namespace std
20
  ```
21
 
22
  ##### `bad_function_call` constructor <a id="func.wrap.badcall.const">[[func.wrap.badcall.const]]</a>
23
 
24
  ``` cpp
25
  bad_function_call() noexcept;
26
  ```
27
 
28
- *Effects:* constructs a `bad_function_call` object.
 
 
29
 
30
  #### Class template `function` <a id="func.wrap.func">[[func.wrap.func]]</a>
31
 
32
  ``` cpp
33
  namespace std {
34
- template<class> class function; // undefined
35
 
36
  template<class R, class... ArgTypes>
37
  class function<R(ArgTypes...)> {
38
  public:
39
- typedef R result_type;
40
- typedef T1 argument_type; // only if sizeof...(ArgTypes) == 1 and
41
- // the type in ArgTypes is T1
42
- typedef T1 first_argument_type; // only if sizeof...(ArgTypes) == 2 and
43
- // ArgTypes contains T1 and T2
44
- typedef T2 second_argument_type; // only if sizeof...(ArgTypes) == 2 and
45
- // ArgTypes contains T1 and T2
46
 
47
- // [func.wrap.func.con], construct/copy/destroy:
48
  function() noexcept;
49
  function(nullptr_t) noexcept;
50
  function(const function&);
51
  function(function&&);
52
  template<class F> function(F);
53
- template<class A> function(allocator_arg_t, const A&) noexcept;
54
- template<class A> function(allocator_arg_t, const A&,
55
- nullptr_t) noexcept;
56
- template<class A> function(allocator_arg_t, const A&,
57
- const function&);
58
- template<class A> function(allocator_arg_t, const A&,
59
- function&&);
60
- template<class F, class A> function(allocator_arg_t, const A&, F);
61
 
62
  function& operator=(const function&);
63
  function& operator=(function&&);
64
- function& operator=(nullptr_t);
65
  template<class F> function& operator=(F&&);
66
  template<class F> function& operator=(reference_wrapper<F>) noexcept;
67
 
68
  ~function();
69
 
70
- // [func.wrap.func.mod], function modifiers:
71
  void swap(function&) noexcept;
72
- template<class F, class A> void assign(F&&, const A&);
73
 
74
- // [func.wrap.func.cap], function capacity:
75
  explicit operator bool() const noexcept;
76
 
77
- // [func.wrap.func.inv], function invocation:
78
  R operator()(ArgTypes...) const;
79
 
80
- // [func.wrap.func.targ], function target access:
81
- const std::type_info& target_type() const noexcept;
82
  template<class T> T* target() noexcept;
83
  template<class T> const T* target() const noexcept;
84
-
85
  };
86
 
87
- // [func.wrap.func.nullptr], Null pointer comparisons:
 
 
 
 
 
88
  template <class R, class... ArgTypes>
89
  bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
90
 
91
  template <class R, class... ArgTypes>
92
  bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
@@ -95,154 +86,176 @@ namespace std {
95
  bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
96
 
97
  template <class R, class... ArgTypes>
98
  bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
99
 
100
- // [func.wrap.func.alg], specialized algorithms:
101
  template <class R, class... ArgTypes>
102
- void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&);
103
-
104
- template<class R, class... ArgTypes, class Alloc>
105
- struct uses_allocator<function<R(ArgTypes...)>, Alloc>
106
- : true_type { };
107
  }
108
  ```
109
 
110
  The `function` class template provides polymorphic wrappers that
111
  generalize the notion of a function pointer. Wrappers can store, copy,
112
  and call arbitrary callable objects ([[func.def]]), given a call
113
  signature ([[func.def]]), allowing functions to be first-class objects.
114
 
115
- A callable object `f` of type `F` is *Callable* for argument types
116
- `ArgTypes` and return type `R` if the expression
117
- `INVOKE(f, declval<ArgTypes>()..., R)`, considered as an unevaluated
118
- operand (Clause  [[expr]]), is well formed ([[func.require]]).
 
119
 
120
  The `function` class template is a call wrapper ([[func.def]]) whose
121
  call signature ([[func.def]]) is `R(ArgTypes...)`.
122
 
 
 
 
123
  ##### `function` construct/copy/destroy <a id="func.wrap.func.con">[[func.wrap.func.con]]</a>
124
 
125
- When any `function` constructor that takes a first argument of type
126
- `allocator_arg_t` is invoked, the second argument shall have a type that
127
- conforms to the requirements for Allocator (Table 
128
- [[allocator.requirements]]). A copy of the allocator argument is used to
129
- allocate memory, if necessary, for the internal data structures of the
130
- constructed `function` object.
131
-
132
  ``` cpp
133
  function() noexcept;
134
- template <class A> function(allocator_arg_t, const A& a) noexcept;
135
  ```
136
 
137
  *Postconditions:* `!*this`.
138
 
139
  ``` cpp
140
  function(nullptr_t) noexcept;
141
- template <class A> function(allocator_arg_t, const A& a, nullptr_t) noexcept;
142
  ```
143
 
144
  *Postconditions:* `!*this`.
145
 
146
  ``` cpp
147
  function(const function& f);
148
- template <class A> function(allocator_arg_t, const A& a, const function& f);
149
  ```
150
 
151
  *Postconditions:* `!*this` if `!f`; otherwise, `*this` targets a copy of
152
  `f.target()`.
153
 
154
- *Throws:* shall not throw exceptions if `f`’s target is a callable
155
- object passed via `reference_wrapper` or a function pointer. Otherwise,
156
- may throw `bad_alloc` or any exception thrown by the copy constructor of
157
- the stored callable object. Implementations are encouraged to avoid the
158
- use of dynamically allocated memory for small callable objects, for
159
- example, where `f`’s target is an object holding only a pointer or
160
- reference to an object and a member function pointer.
 
 
161
 
162
  ``` cpp
163
  function(function&& f);
164
- template <class A> function(allocator_arg_t, const A& a, function&& f);
165
  ```
166
 
167
- *Effects:* If `!f`, `*this` has no target; otherwise, move-constructs
168
- the target of `f` into the target of `*this`, leaving `f` in a valid
169
- state with an unspecified value.
 
 
 
 
 
 
 
 
 
 
170
 
171
  ``` cpp
172
  template<class F> function(F f);
173
- template <class F, class A> function(allocator_arg_t, const A& a, F f);
174
  ```
175
 
176
  *Requires:* `F` shall be `CopyConstructible`.
177
 
178
- *Remarks:* These constructors shall not participate in overload
179
- resolution unless `f` is Callable ([[func.wrap.func]]) for argument
180
- types `ArgTypes...` and return type `R`.
181
 
182
  *Postconditions:* `!*this` if any of the following hold:
183
 
184
  - `f` is a null function pointer value.
185
  - `f` is a null member pointer value.
186
  - `F` is an instance of the `function` class template, and `!f`.
187
 
188
  Otherwise, `*this` targets a copy of `f` initialized with
189
- `std::move(f)`. Implementations are encouraged to avoid the use of
 
 
190
  dynamically allocated memory for small callable objects, for example,
191
- where `f`’s target is an object holding only a pointer or reference to
192
- an object and a member function pointer.
193
 
194
  *Throws:* shall not throw exceptions when `f` is a function pointer or a
195
  `reference_wrapper<T>` for some `T`. Otherwise, may throw `bad_alloc` or
196
  any exception thrown by `F`’s copy or move constructor.
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  ``` cpp
199
  function& operator=(const function& f);
200
  ```
201
 
202
- *Effects:* `function(f).swap(*this);`
203
 
204
- *Returns:* `*this`
205
 
206
  ``` cpp
207
  function& operator=(function&& f);
208
  ```
209
 
210
  *Effects:* Replaces the target of `*this` with the target of `f`.
211
 
212
- *Returns:* `*this`
213
 
214
  ``` cpp
215
- function& operator=(nullptr_t);
216
  ```
217
 
218
  *Effects:* If `*this != nullptr`, destroys the target of `this`.
219
 
220
  *Postconditions:* `!(*this)`.
221
 
222
- *Returns:* `*this`
223
 
224
  ``` cpp
225
  template<class F> function& operator=(F&& f);
226
  ```
227
 
228
- *Effects:* `function(std::forward<F>(f)).swap(*this);`
229
 
230
- *Returns:* `*this`
231
 
232
  *Remarks:* This assignment operator shall not participate in overload
233
- resolution unless `declval<typename decay<F>::type&>()` is
234
- Callable ([[func.wrap.func]]) for argument types `ArgTypes...` and
235
- return type `R`.
236
 
237
  ``` cpp
238
  template<class F> function& operator=(reference_wrapper<F> f) noexcept;
239
  ```
240
 
241
- *Effects:* `function(f).swap(*this);`
242
 
243
- *Returns:* `*this`
244
 
245
  ``` cpp
246
  ~function();
247
  ```
248
 
@@ -254,17 +267,10 @@ template<class F> function& operator=(reference_wrapper<F> f) noexcept;
254
  void swap(function& other) noexcept;
255
  ```
256
 
257
  *Effects:* interchanges the targets of `*this` and `other`.
258
 
259
- ``` cpp
260
- template<class F, class A>
261
- void assign(F&& f, const A& a);
262
- ```
263
-
264
- *Effects:* `function(allocator_arg, a, std::forward<F>(f)).swap(*this)`
265
-
266
  ##### `function` capacity <a id="func.wrap.func.cap">[[func.wrap.func.cap]]</a>
267
 
268
  ``` cpp
269
  explicit operator bool() const noexcept;
270
  ```
@@ -272,44 +278,38 @@ explicit operator bool() const noexcept;
272
  *Returns:* `true` if `*this` has a target, otherwise `false`.
273
 
274
  ##### `function` invocation <a id="func.wrap.func.inv">[[func.wrap.func.inv]]</a>
275
 
276
  ``` cpp
277
- R operator()(ArgTypes... args) const
278
  ```
279
 
280
- *Effects:*
281
- *`INVOKE`*`(f, std::forward<ArgTypes>(args)..., R)` ([[func.require]]),
282
- where `f` is the target object ([[func.def]]) of `*this`.
283
-
284
- *Returns:* Nothing if `R` is `void`, otherwise the return value of
285
- *`INVOKE`*`(f, std::forward<ArgTypes>(args)..., R)`.
286
 
287
  *Throws:* `bad_function_call` if `!*this`; otherwise, any exception
288
  thrown by the wrapped callable object.
289
 
290
- ##### function target access <a id="func.wrap.func.targ">[[func.wrap.func.targ]]</a>
291
 
292
  ``` cpp
293
- const std::type_info& target_type() const noexcept;
294
  ```
295
 
296
  *Returns:* If `*this` has a target of type `T`, `typeid(T)`; otherwise,
297
  `typeid(void)`.
298
 
299
  ``` cpp
300
  template<class T> T* target() noexcept;
301
  template<class T> const T* target() const noexcept;
302
  ```
303
 
304
- *Requires:* `T` shall be a type that is Callable ([[func.wrap.func]])
305
- for parameter types `ArgTypes` and return type `R`.
306
-
307
  *Returns:* If `target_type() == typeid(T)` a pointer to the stored
308
  function target; otherwise a null pointer.
309
 
310
- ##### null pointer comparison operators <a id="func.wrap.func.nullptr">[[func.wrap.func.nullptr]]</a>
311
 
312
  ``` cpp
313
  template <class R, class... ArgTypes>
314
  bool operator==(const function<R(ArgTypes...)>& f, nullptr_t) noexcept;
315
  template <class R, class... ArgTypes>
@@ -329,10 +329,10 @@ template <class R, class... ArgTypes>
329
 
330
  ##### specialized algorithms <a id="func.wrap.func.alg">[[func.wrap.func.alg]]</a>
331
 
332
  ``` cpp
333
  template<class R, class... ArgTypes>
334
- void swap(function<R(ArgTypes...)>& f1, function<R(ArgTypes...)>& f2);
335
  ```
336
 
337
- *Effects:* `f1.swap(f2);`
338
 
 
9
  `function::operator()` ([[func.wrap.func.inv]]) when the function
10
  wrapper object has no target.
11
 
12
  ``` cpp
13
  namespace std {
14
+ class bad_function_call : public exception {
15
  public:
16
+ // [func.wrap.badcall.const], constructor
17
  bad_function_call() noexcept;
18
  };
19
+ }
20
  ```
21
 
22
  ##### `bad_function_call` constructor <a id="func.wrap.badcall.const">[[func.wrap.badcall.const]]</a>
23
 
24
  ``` cpp
25
  bad_function_call() noexcept;
26
  ```
27
 
28
+ *Effects:* Constructs a `bad_function_call` object.
29
+
30
+ *Postconditions:* `what()` returns an *implementation-defined* NTBS.
31
 
32
  #### Class template `function` <a id="func.wrap.func">[[func.wrap.func]]</a>
33
 
34
  ``` cpp
35
  namespace std {
36
+ template<class> class function; // not defined
37
 
38
  template<class R, class... ArgTypes>
39
  class function<R(ArgTypes...)> {
40
  public:
41
+ using result_type = R;
 
 
 
 
 
 
42
 
43
+ // [func.wrap.func.con], construct/copy/destroy
44
  function() noexcept;
45
  function(nullptr_t) noexcept;
46
  function(const function&);
47
  function(function&&);
48
  template<class F> function(F);
 
 
 
 
 
 
 
 
49
 
50
  function& operator=(const function&);
51
  function& operator=(function&&);
52
+ function& operator=(nullptr_t) noexcept;
53
  template<class F> function& operator=(F&&);
54
  template<class F> function& operator=(reference_wrapper<F>) noexcept;
55
 
56
  ~function();
57
 
58
+ // [func.wrap.func.mod], function modifiers
59
  void swap(function&) noexcept;
 
60
 
61
+ // [func.wrap.func.cap], function capacity
62
  explicit operator bool() const noexcept;
63
 
64
+ // [func.wrap.func.inv], function invocation
65
  R operator()(ArgTypes...) const;
66
 
67
+ // [func.wrap.func.targ], function target access
68
+ const type_info& target_type() const noexcept;
69
  template<class T> T* target() noexcept;
70
  template<class T> const T* target() const noexcept;
 
71
  };
72
 
73
+ template<class R, class... ArgTypes>
74
+ function(R(*)(ArgTypes...)) -> function<R(ArgTypes...)>;
75
+
76
+ template<class F> function(F) -> function<see below>;
77
+
78
+ // [func.wrap.func.nullptr], Null pointer comparisons
79
  template <class R, class... ArgTypes>
80
  bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
81
 
82
  template <class R, class... ArgTypes>
83
  bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
 
86
  bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept;
87
 
88
  template <class R, class... ArgTypes>
89
  bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept;
90
 
91
+ // [func.wrap.func.alg], specialized algorithms
92
  template <class R, class... ArgTypes>
93
+ void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
 
 
 
 
94
  }
95
  ```
96
 
97
  The `function` class template provides polymorphic wrappers that
98
  generalize the notion of a function pointer. Wrappers can store, copy,
99
  and call arbitrary callable objects ([[func.def]]), given a call
100
  signature ([[func.def]]), allowing functions to be first-class objects.
101
 
102
+ A callable type ([[func.def]]) `F` is *Lvalue-Callable* for argument
103
+ types `ArgTypes` and return type `R` if the expression
104
+ `INVOKE<R>(declval<F&>(), declval<ArgTypes>()...)`, considered as an
105
+ unevaluated operand (Clause  [[expr]]), is well formed (
106
+ [[func.require]]).
107
 
108
  The `function` class template is a call wrapper ([[func.def]]) whose
109
  call signature ([[func.def]]) is `R(ArgTypes...)`.
110
 
111
+ [*Note 1*: The types deduced by the deduction guides for `function` may
112
+ change in future versions of this International Standard. — *end note*]
113
+
114
  ##### `function` construct/copy/destroy <a id="func.wrap.func.con">[[func.wrap.func.con]]</a>
115
 
 
 
 
 
 
 
 
116
  ``` cpp
117
  function() noexcept;
 
118
  ```
119
 
120
  *Postconditions:* `!*this`.
121
 
122
  ``` cpp
123
  function(nullptr_t) noexcept;
 
124
  ```
125
 
126
  *Postconditions:* `!*this`.
127
 
128
  ``` cpp
129
  function(const function& f);
 
130
  ```
131
 
132
  *Postconditions:* `!*this` if `!f`; otherwise, `*this` targets a copy of
133
  `f.target()`.
134
 
135
+ *Throws:* shall not throw exceptions if `f`’s target is a specialization
136
+ of `reference_wrapper` or a function pointer. Otherwise, may throw
137
+ `bad_alloc` or any exception thrown by the copy constructor of the
138
+ stored callable object.
139
+
140
+ [*Note 1*: Implementations are encouraged to avoid the use of
141
+ dynamically allocated memory for small callable objects, for example,
142
+ where `f`’s target is an object holding only a pointer or reference to
143
+ an object and a member function pointer. — *end note*]
144
 
145
  ``` cpp
146
  function(function&& f);
 
147
  ```
148
 
149
+ *Postconditions:* If `!f`, `*this` has no target; otherwise, the target
150
+ of `*this` is equivalent to the target of `f` before the construction,
151
+ and `f` is in a valid state with an unspecified value.
152
+
153
+ *Throws:* shall not throw exceptions if `f`’s target is a specialization
154
+ of `reference_wrapper` or a function pointer. Otherwise, may throw
155
+ `bad_alloc` or any exception thrown by the copy or move constructor of
156
+ the stored callable object.
157
+
158
+ [*Note 2*: Implementations are encouraged to avoid the use of
159
+ dynamically allocated memory for small callable objects, for example,
160
+ where `f`’s target is an object holding only a pointer or reference to
161
+ an object and a member function pointer. — *end note*]
162
 
163
  ``` cpp
164
  template<class F> function(F f);
 
165
  ```
166
 
167
  *Requires:* `F` shall be `CopyConstructible`.
168
 
169
+ *Remarks:* This constructor template shall not participate in overload
170
+ resolution unless `F` is Lvalue-Callable ([[func.wrap.func]]) for
171
+ argument types `ArgTypes...` and return type `R`.
172
 
173
  *Postconditions:* `!*this` if any of the following hold:
174
 
175
  - `f` is a null function pointer value.
176
  - `f` is a null member pointer value.
177
  - `F` is an instance of the `function` class template, and `!f`.
178
 
179
  Otherwise, `*this` targets a copy of `f` initialized with
180
+ `std::move(f)`.
181
+
182
+ [*Note 3*: Implementations are encouraged to avoid the use of
183
  dynamically allocated memory for small callable objects, for example,
184
+ where `f` is an object holding only a pointer or reference to an object
185
+ and a member function pointer. — *end note*]
186
 
187
  *Throws:* shall not throw exceptions when `f` is a function pointer or a
188
  `reference_wrapper<T>` for some `T`. Otherwise, may throw `bad_alloc` or
189
  any exception thrown by `F`’s copy or move constructor.
190
 
191
+ ``` cpp
192
+ template<class F> function(F) -> function<see below>;
193
+ ```
194
+
195
+ *Remarks:* This deduction guide participates in overload resolution only
196
+ if `&F::operator()` is well-formed when treated as an unevaluated
197
+ operand. In that case, if `decltype(&F::operator())` is of the form
198
+ `R(G::*)(A...)` cv `&`ₒₚₜ ` noexcept` for a class type `G`, then the
199
+ deduced type is `function<R(A...)>`.
200
+
201
+ [*Example 1*:
202
+
203
+ ``` cpp
204
+ void f() {
205
+ int i{5};
206
+ function g = [&](double) { return i; }; // deduces function<int(double)>
207
+ }
208
+ ```
209
+
210
+ — *end example*]
211
+
212
  ``` cpp
213
  function& operator=(const function& f);
214
  ```
215
 
216
+ *Effects:* As if by `function(f).swap(*this);`
217
 
218
+ *Returns:* `*this`.
219
 
220
  ``` cpp
221
  function& operator=(function&& f);
222
  ```
223
 
224
  *Effects:* Replaces the target of `*this` with the target of `f`.
225
 
226
+ *Returns:* `*this`.
227
 
228
  ``` cpp
229
+ function& operator=(nullptr_t) noexcept;
230
  ```
231
 
232
  *Effects:* If `*this != nullptr`, destroys the target of `this`.
233
 
234
  *Postconditions:* `!(*this)`.
235
 
236
+ *Returns:* `*this`.
237
 
238
  ``` cpp
239
  template<class F> function& operator=(F&& f);
240
  ```
241
 
242
+ *Effects:* As if by: `function(std::forward<F>(f)).swap(*this);`
243
 
244
+ *Returns:* `*this`.
245
 
246
  *Remarks:* This assignment operator shall not participate in overload
247
+ resolution unless `decay_t<F>` is Lvalue-Callable ([[func.wrap.func]])
248
+ for argument types `ArgTypes...` and return type `R`.
 
249
 
250
  ``` cpp
251
  template<class F> function& operator=(reference_wrapper<F> f) noexcept;
252
  ```
253
 
254
+ *Effects:* As if by: `function(f).swap(*this);`
255
 
256
+ *Returns:* `*this`.
257
 
258
  ``` cpp
259
  ~function();
260
  ```
261
 
 
267
  void swap(function& other) noexcept;
268
  ```
269
 
270
  *Effects:* interchanges the targets of `*this` and `other`.
271
 
 
 
 
 
 
 
 
272
  ##### `function` capacity <a id="func.wrap.func.cap">[[func.wrap.func.cap]]</a>
273
 
274
  ``` cpp
275
  explicit operator bool() const noexcept;
276
  ```
 
278
  *Returns:* `true` if `*this` has a target, otherwise `false`.
279
 
280
  ##### `function` invocation <a id="func.wrap.func.inv">[[func.wrap.func.inv]]</a>
281
 
282
  ``` cpp
283
+ R operator()(ArgTypes... args) const;
284
  ```
285
 
286
+ *Returns:* *INVOKE*\<R\>(f,
287
+ std::forward\<ArgTypes\>(args)...) ([[func.require]]), where `f` is the
288
+ target object ([[func.def]]) of `*this`.
 
 
 
289
 
290
  *Throws:* `bad_function_call` if `!*this`; otherwise, any exception
291
  thrown by the wrapped callable object.
292
 
293
+ ##### `function` target access <a id="func.wrap.func.targ">[[func.wrap.func.targ]]</a>
294
 
295
  ``` cpp
296
+ const type_info& target_type() const noexcept;
297
  ```
298
 
299
  *Returns:* If `*this` has a target of type `T`, `typeid(T)`; otherwise,
300
  `typeid(void)`.
301
 
302
  ``` cpp
303
  template<class T> T* target() noexcept;
304
  template<class T> const T* target() const noexcept;
305
  ```
306
 
 
 
 
307
  *Returns:* If `target_type() == typeid(T)` a pointer to the stored
308
  function target; otherwise a null pointer.
309
 
310
+ ##### null pointer comparison functions <a id="func.wrap.func.nullptr">[[func.wrap.func.nullptr]]</a>
311
 
312
  ``` cpp
313
  template <class R, class... ArgTypes>
314
  bool operator==(const function<R(ArgTypes...)>& f, nullptr_t) noexcept;
315
  template <class R, class... ArgTypes>
 
329
 
330
  ##### specialized algorithms <a id="func.wrap.func.alg">[[func.wrap.func.alg]]</a>
331
 
332
  ``` cpp
333
  template<class R, class... ArgTypes>
334
+ void swap(function<R(ArgTypes...)>& f1, function<R(ArgTypes...)>& f2) noexcept;
335
  ```
336
 
337
+ *Effects:* As if by: `f1.swap(f2);`
338