40 lines
1.6 KiB
Markdown
40 lines
1.6 KiB
Markdown
[func.wrap.general]
|
||
|
||
# 22 General utilities library [[utilities]](./#utilities)
|
||
|
||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.general)
|
||
|
||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#general)
|
||
|
||
#### 22.10.17.1 General [func.wrap.general]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13594)
|
||
|
||
Subclause [[func.wrap]](func.wrap "22.10.17 Polymorphic function wrappers") describes polymorphic wrapper classes that
|
||
encapsulate arbitrary callable objects[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13598)
|
||
|
||
Let t be an object of a type that is a specialization offunction, copyable_function, or move_only_function,
|
||
such that the target object x of t has a type that
|
||
is a specialization offunction, copyable_function, or move_only_function[.](#2.sentence-1)
|
||
|
||
Each argument of the
|
||
invocation of x evaluated as part of the invocation of t may alias an argument in the same position in the invocation of t that
|
||
has the same type, even if the corresponding parameter is not of reference type[.](#2.sentence-2)
|
||
|
||
[*Example [1](#example-1)*: move_only_function<void(T)> f{copyable_function<void(T)>{[](T) {}}};
|
||
T t;
|
||
f(t); // it is unspecified how many copies of T are made â *end example*]
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13616)
|
||
|
||
*Recommended practice*: Implementations should avoid double wrapping when
|
||
constructing polymorphic wrappers from one another[.](#3.sentence-1)
|