Files
2025-10-25 03:02:53 +03:00

40 lines
1.6 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.17Polymorphic 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)