Init
This commit is contained in:
29
cppdraft/func/wrap/badcall.md
Normal file
29
cppdraft/func/wrap/badcall.md
Normal file
@@ -0,0 +1,29 @@
|
||||
[func.wrap.badcall]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.badcall)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#badcall)
|
||||
|
||||
#### 22.10.17.2 Class bad_function_call [func.wrap.badcall]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13624)
|
||||
|
||||
An exception of type bad_function_call is thrown byfunction::operator() ([[func.wrap.func.inv]](func.wrap.func.inv "22.10.17.3.5 Invocation"))
|
||||
when the function wrapper object has no target[.](#1.sentence-1)
|
||||
|
||||
namespace std {class bad_function_call : public exception {public:// see [[exception]](exception "17.9.3 Class exception") for the specification of the special member functionsconst char* what() const noexcept override; };}
|
||||
|
||||
[ð](#lib:what,bad_function_call)
|
||||
|
||||
`const char* what() const noexcept override;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13645)
|
||||
|
||||
*Returns*: Animplementation-defined ntbs[.](#2.sentence-1)
|
||||
489
cppdraft/func/wrap/copy.md
Normal file
489
cppdraft/func/wrap/copy.md
Normal file
@@ -0,0 +1,489 @@
|
||||
[func.wrap.copy]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.copy)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#copy)
|
||||
|
||||
#### 22.10.17.5 Copyable wrapper [func.wrap.copy]
|
||||
|
||||
#### [22.10.17.5.1](#general) General [[func.wrap.copy.general]](func.wrap.copy.general)
|
||||
|
||||
[1](#general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14482)
|
||||
|
||||
The header provides partial specializations of copyable_function for each combination of the possible replacements
|
||||
of the placeholders cv, *ref*, and *noex* where
|
||||
|
||||
- [(1.1)](#general-1.1)
|
||||
|
||||
cv is either const or empty,
|
||||
|
||||
- [(1.2)](#general-1.2)
|
||||
|
||||
*ref* is either &, &&, or empty, and
|
||||
|
||||
- [(1.3)](#general-1.3)
|
||||
|
||||
*noex* is either true or false[.](#general-1.sentence-1)
|
||||
|
||||
[2](#general-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14495)
|
||||
|
||||
For each of the possible combinations of the placeholders mentioned above,
|
||||
there is a placeholder *inv-quals* defined as follows:
|
||||
|
||||
- [(2.1)](#general-2.1)
|
||||
|
||||
If *ref* is empty, let *inv-quals* be cv&,
|
||||
|
||||
- [(2.2)](#general-2.2)
|
||||
|
||||
otherwise, let *inv-quals* be cv *ref*[.](#general-2.sentence-1)
|
||||
|
||||
#### [22.10.17.5.2](#class) Class template copyable_function [[func.wrap.copy.class]](func.wrap.copy.class)
|
||||
|
||||
[ð](#lib:copyable_function)
|
||||
|
||||
namespace std {template<class R, class... ArgTypes>class copyable_function<R(ArgTypes...) cv *ref* noexcept(*noex*)> {public:using result_type = R; // [[func.wrap.copy.ctor]](#ctor "22.10.17.5.3 Constructors, assignments, and destructor"), constructors, assignments, and destructor copyable_function() noexcept;
|
||||
copyable_function(nullptr_t) noexcept;
|
||||
copyable_function(const copyable_function&);
|
||||
copyable_function(copyable_function&&) noexcept; template<class F> copyable_function(F&&); template<class T, class... Args>explicit copyable_function(in_place_type_t<T>, Args&&...); template<class T, class U, class... Args>explicit copyable_function(in_place_type_t<T>, initializer_list<U>, Args&&...);
|
||||
|
||||
copyable_function& operator=(const copyable_function&);
|
||||
copyable_function& operator=(copyable_function&&);
|
||||
copyable_function& operator=(nullptr_t) noexcept; template<class F> copyable_function& operator=(F&&); ~copyable_function(); // [[func.wrap.copy.inv]](#inv "22.10.17.5.4 Invocation"), invocationexplicit operator bool() const noexcept;
|
||||
R operator()(ArgTypes...) cv *ref* noexcept(*noex*); // [[func.wrap.copy.util]](#util "22.10.17.5.5 Utility"), utilityvoid swap(copyable_function&) noexcept; friend void swap(copyable_function&, copyable_function&) noexcept; friend bool operator==(const copyable_function&, nullptr_t) noexcept; private:template<class VT>static constexpr bool *is-callable-from* = *see below*; // *exposition only*};}
|
||||
|
||||
[1](#class-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14549)
|
||||
|
||||
The copyable_function class template provides polymorphic wrappers
|
||||
that generalize the notion of a callable object ([[func.def]](func.def "22.10.3 Definitions"))[.](#class-1.sentence-1)
|
||||
|
||||
These wrappers can store, copy, move, and call arbitrary callable objects,
|
||||
given a call signature[.](#class-1.sentence-2)
|
||||
|
||||
[2](#class-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14555)
|
||||
|
||||
*Recommended practice*: Implementations should avoid the use of dynamically allocated memory
|
||||
for a small contained value[.](#class-2.sentence-1)
|
||||
|
||||
[*Note [1](#class-note-1)*:
|
||||
|
||||
Such small-object optimization can only be applied to a type T for which is_nothrow_move_constructible_v<T> is true[.](#class-2.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
#### [22.10.17.5.3](#ctor) Constructors, assignments, and destructor [[func.wrap.copy.ctor]](func.wrap.copy.ctor)
|
||||
|
||||
[ð](#:copyable_function::is-callable-from)
|
||||
|
||||
`template<class VT>
|
||||
static constexpr bool is-callable-from = see below;
|
||||
`
|
||||
|
||||
[1](#ctor-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14573)
|
||||
|
||||
If *noex* is true,*is-callable-from*<VT> is equal to:is_nothrow_invocable_r_v<R, VT cv *ref*, ArgTypes...> && is_nothrow_invocable_r_v<R, VT *inv-quals*, ArgTypes...>
|
||||
|
||||
Otherwise, *is-callable-from*<VT> is equal to:is_invocable_r_v<R, VT cv *ref*, ArgTypes...> && is_invocable_r_v<R, VT *inv-quals*, ArgTypes...>
|
||||
|
||||
[ð](#lib:copyable_function,constructor)
|
||||
|
||||
`copyable_function() noexcept;
|
||||
copyable_function(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[2](#ctor-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14594)
|
||||
|
||||
*Postconditions*: *this has no target object[.](#ctor-2.sentence-1)
|
||||
|
||||
[ð](#lib:copyable_function,constructor_)
|
||||
|
||||
`copyable_function(const copyable_function& f);
|
||||
`
|
||||
|
||||
[3](#ctor-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14605)
|
||||
|
||||
*Postconditions*: *this has no target object if f had no target object[.](#ctor-3.sentence-1)
|
||||
|
||||
Otherwise, the target object of *this is a copy of the target object of f[.](#ctor-3.sentence-2)
|
||||
|
||||
[4](#ctor-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14611)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#ctor-4.sentence-1)
|
||||
|
||||
May throw bad_alloc[.](#ctor-4.sentence-2)
|
||||
|
||||
[ð](#lib:copyable_function,constructor__)
|
||||
|
||||
`copyable_function(copyable_function&& f) noexcept;
|
||||
`
|
||||
|
||||
[5](#ctor-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14623)
|
||||
|
||||
*Postconditions*: The target object of *this is
|
||||
the target object f had before construction, andf is in a valid state with an unspecified value[.](#ctor-5.sentence-1)
|
||||
|
||||
[ð](#lib:copyable_function,constructor___)
|
||||
|
||||
`template<class F> copyable_function(F&& f);
|
||||
`
|
||||
|
||||
[6](#ctor-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14636)
|
||||
|
||||
Let VT be decay_t<F>[.](#ctor-6.sentence-1)
|
||||
|
||||
[7](#ctor-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14639)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(7.1)](#ctor-7.1)
|
||||
|
||||
remove_cvref_t<F> is not the same type as copyable_function, and
|
||||
|
||||
- [(7.2)](#ctor-7.2)
|
||||
|
||||
remove_cvref_t<F> is not a specialization of in_place_type_t, and
|
||||
|
||||
- [(7.3)](#ctor-7.3)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#ctor-7.sentence-1)
|
||||
|
||||
[8](#ctor-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14650)
|
||||
|
||||
*Mandates*:
|
||||
|
||||
- [(8.1)](#ctor-8.1)
|
||||
|
||||
is_constructible_v<VT, F> is true, and
|
||||
|
||||
- [(8.2)](#ctor-8.2)
|
||||
|
||||
is_copy_constructible_v<VT> is true[.](#ctor-8.sentence-1)
|
||||
|
||||
[9](#ctor-9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14659)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#ctor-9.sentence-1)
|
||||
|
||||
[10](#ctor-10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14664)
|
||||
|
||||
*Postconditions*: *this has no target object if any of the following hold:
|
||||
|
||||
- [(10.1)](#ctor-10.1)
|
||||
|
||||
f is a null function pointer value, or
|
||||
|
||||
- [(10.2)](#ctor-10.2)
|
||||
|
||||
f is a null member pointer value, or
|
||||
|
||||
- [(10.3)](#ctor-10.3)
|
||||
|
||||
remove_cvref_t<F> is a specialization of
|
||||
the copyable_function class template,
|
||||
and f has no target object[.](#ctor-10.sentence-1)
|
||||
|
||||
Otherwise, *this has a target object of type VT direct-non-list-initialized with std::forward<F>(f)[.](#ctor-10.sentence-2)
|
||||
|
||||
[11](#ctor-11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14680)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#ctor-11.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a function pointer or a specialization of reference_wrapper[.](#ctor-11.sentence-2)
|
||||
|
||||
[ð](#lib:copyable_function,constructor____)
|
||||
|
||||
`template<class T, class... Args>
|
||||
explicit copyable_function(in_place_type_t<T>, Args&&... args);
|
||||
`
|
||||
|
||||
[12](#ctor-12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14694)
|
||||
|
||||
Let VT be decay_t<T>[.](#ctor-12.sentence-1)
|
||||
|
||||
[13](#ctor-13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14697)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(13.1)](#ctor-13.1)
|
||||
|
||||
is_constructible_v<VT, Args...> is true, and
|
||||
|
||||
- [(13.2)](#ctor-13.2)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#ctor-13.sentence-1)
|
||||
|
||||
[14](#ctor-14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14706)
|
||||
|
||||
*Mandates*:
|
||||
|
||||
- [(14.1)](#ctor-14.1)
|
||||
|
||||
VT is the same type as T, and
|
||||
|
||||
- [(14.2)](#ctor-14.2)
|
||||
|
||||
is_copy_constructible_v<VT> is true[.](#ctor-14.sentence-1)
|
||||
|
||||
[15](#ctor-15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14715)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#ctor-15.sentence-1)
|
||||
|
||||
[16](#ctor-16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14720)
|
||||
|
||||
*Postconditions*: *this has a target object of type VT direct-non-list-initialized with std::forward<Args>(args)...[.](#ctor-16.sentence-1)
|
||||
|
||||
[17](#ctor-17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14725)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#ctor-17.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a pointer or a specialization of reference_wrapper[.](#ctor-17.sentence-2)
|
||||
|
||||
[ð](#lib:copyable_function,constructor_____)
|
||||
|
||||
`template<class T, class U, class... Args>
|
||||
explicit copyable_function(in_place_type_t<T>, initializer_list<U> ilist, Args&&... args);
|
||||
`
|
||||
|
||||
[18](#ctor-18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14739)
|
||||
|
||||
Let VT be decay_t<T>[.](#ctor-18.sentence-1)
|
||||
|
||||
[19](#ctor-19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14742)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(19.1)](#ctor-19.1)
|
||||
|
||||
is_constructible_v<VT, initializer_list<U>&, Args...> istrue, and
|
||||
|
||||
- [(19.2)](#ctor-19.2)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#ctor-19.sentence-1)
|
||||
|
||||
[20](#ctor-20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14752)
|
||||
|
||||
*Mandates*:
|
||||
|
||||
- [(20.1)](#ctor-20.1)
|
||||
|
||||
VT is the same type as T, and
|
||||
|
||||
- [(20.2)](#ctor-20.2)
|
||||
|
||||
is_copy_constructible_v<VT> is true[.](#ctor-20.sentence-1)
|
||||
|
||||
[21](#ctor-21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14761)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#ctor-21.sentence-1)
|
||||
|
||||
[22](#ctor-22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14766)
|
||||
|
||||
*Postconditions*: *this has a target object of type VT direct-non-list-initialized withilist, std::forward<Args>(args)...[.](#ctor-22.sentence-1)
|
||||
|
||||
[23](#ctor-23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14772)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#ctor-23.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a pointer or a specialization of reference_wrapper[.](#ctor-23.sentence-2)
|
||||
|
||||
[ð](#lib:operator=,copyable_function)
|
||||
|
||||
`copyable_function& operator=(const copyable_function& f);
|
||||
`
|
||||
|
||||
[24](#ctor-24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14785)
|
||||
|
||||
*Effects*: Equivalent to: copyable_function(f).swap(*this);
|
||||
|
||||
[25](#ctor-25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14789)
|
||||
|
||||
*Returns*: *this[.](#ctor-25.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,copyable_function_)
|
||||
|
||||
`copyable_function& operator=(copyable_function&& f);
|
||||
`
|
||||
|
||||
[26](#ctor-26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14800)
|
||||
|
||||
*Effects*: Equivalent to: copyable_function(std::move(f)).swap(*this);
|
||||
|
||||
[27](#ctor-27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14804)
|
||||
|
||||
*Returns*: *this[.](#ctor-27.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,copyable_function__)
|
||||
|
||||
`copyable_function& operator=(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[28](#ctor-28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14815)
|
||||
|
||||
*Effects*: Destroys the target object of *this, if any[.](#ctor-28.sentence-1)
|
||||
|
||||
[29](#ctor-29)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14819)
|
||||
|
||||
*Returns*: *this[.](#ctor-29.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,copyable_function___)
|
||||
|
||||
`template<class F> copyable_function& operator=(F&& f);
|
||||
`
|
||||
|
||||
[30](#ctor-30)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14830)
|
||||
|
||||
*Effects*: Equivalent to: copyable_function(std::forward<F>(f)).swap(*this);
|
||||
|
||||
[31](#ctor-31)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14834)
|
||||
|
||||
*Returns*: *this[.](#ctor-31.sentence-1)
|
||||
|
||||
[ð](#lib:copyable_function,destructor)
|
||||
|
||||
`~copyable_function();
|
||||
`
|
||||
|
||||
[32](#ctor-32)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14845)
|
||||
|
||||
*Effects*: Destroys the target object of *this, if any[.](#ctor-32.sentence-1)
|
||||
|
||||
#### [22.10.17.5.4](#inv) Invocation [[func.wrap.copy.inv]](func.wrap.copy.inv)
|
||||
|
||||
[ð](#lib:operator_bool,copyable_function)
|
||||
|
||||
`explicit operator bool() const noexcept;
|
||||
`
|
||||
|
||||
[1](#inv-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14858)
|
||||
|
||||
*Returns*: true if *this has a target object, otherwise false[.](#inv-1.sentence-1)
|
||||
|
||||
[ð](#lib:operator(),copyable_function)
|
||||
|
||||
`R operator()(ArgTypes... args) cv ref noexcept(noex);
|
||||
`
|
||||
|
||||
[2](#inv-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14869)
|
||||
|
||||
*Preconditions*: *this has a target object[.](#inv-2.sentence-1)
|
||||
|
||||
[3](#inv-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14873)
|
||||
|
||||
*Effects*: Equivalent to:return *INVOKE*<R>(static_cast<F *inv-quals*>(f), std::forward<ArgTypes>(args)...); where f is an lvalue designating the target object of *this andF is the type of f[.](#inv-3.sentence-1)
|
||||
|
||||
#### [22.10.17.5.5](#util) Utility [[func.wrap.copy.util]](func.wrap.copy.util)
|
||||
|
||||
[ð](#lib:swap,copyable_function)
|
||||
|
||||
`void swap(copyable_function& other) noexcept;
|
||||
`
|
||||
|
||||
[1](#util-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14891)
|
||||
|
||||
*Effects*: Exchanges the target objects of *this and other[.](#util-1.sentence-1)
|
||||
|
||||
[ð](#lib:swap,copyable_function_)
|
||||
|
||||
`friend void swap(copyable_function& f1, copyable_function& f2) noexcept;
|
||||
`
|
||||
|
||||
[2](#util-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14902)
|
||||
|
||||
*Effects*: Equivalent to f1.swap(f2)[.](#util-2.sentence-1)
|
||||
|
||||
[ð](#lib:operator==,copyable_function)
|
||||
|
||||
`friend bool operator==(const copyable_function& f, nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[3](#util-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14913)
|
||||
|
||||
*Returns*: true if f has no target object, otherwise false[.](#util-3.sentence-1)
|
||||
46
cppdraft/func/wrap/copy/class.md
Normal file
46
cppdraft/func/wrap/copy/class.md
Normal file
@@ -0,0 +1,46 @@
|
||||
[func.wrap.copy.class]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.copy.class)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#copy.class)
|
||||
|
||||
#### 22.10.17.5 Copyable wrapper [[func.wrap.copy]](func.wrap.copy#class)
|
||||
|
||||
#### 22.10.17.5.2 Class template copyable_function [func.wrap.copy.class]
|
||||
|
||||
[ð](#lib:copyable_function)
|
||||
|
||||
namespace std {template<class R, class... ArgTypes>class copyable_function<R(ArgTypes...) cv *ref* noexcept(*noex*)> {public:using result_type = R; // [[func.wrap.copy.ctor]](func.wrap.copy.ctor "22.10.17.5.3 Constructors, assignments, and destructor"), constructors, assignments, and destructor copyable_function() noexcept;
|
||||
copyable_function(nullptr_t) noexcept;
|
||||
copyable_function(const copyable_function&);
|
||||
copyable_function(copyable_function&&) noexcept; template<class F> copyable_function(F&&); template<class T, class... Args>explicit copyable_function(in_place_type_t<T>, Args&&...); template<class T, class U, class... Args>explicit copyable_function(in_place_type_t<T>, initializer_list<U>, Args&&...);
|
||||
|
||||
copyable_function& operator=(const copyable_function&);
|
||||
copyable_function& operator=(copyable_function&&);
|
||||
copyable_function& operator=(nullptr_t) noexcept; template<class F> copyable_function& operator=(F&&); ~copyable_function(); // [[func.wrap.copy.inv]](func.wrap.copy.inv "22.10.17.5.4 Invocation"), invocationexplicit operator bool() const noexcept;
|
||||
R operator()(ArgTypes...) cv *ref* noexcept(*noex*); // [[func.wrap.copy.util]](func.wrap.copy.util "22.10.17.5.5 Utility"), utilityvoid swap(copyable_function&) noexcept; friend void swap(copyable_function&, copyable_function&) noexcept; friend bool operator==(const copyable_function&, nullptr_t) noexcept; private:template<class VT>static constexpr bool *is-callable-from* = *see below*; // *exposition only*};}
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14549)
|
||||
|
||||
The copyable_function class template provides polymorphic wrappers
|
||||
that generalize the notion of a callable object ([[func.def]](func.def "22.10.3 Definitions"))[.](#1.sentence-1)
|
||||
|
||||
These wrappers can store, copy, move, and call arbitrary callable objects,
|
||||
given a call signature[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14555)
|
||||
|
||||
*Recommended practice*: Implementations should avoid the use of dynamically allocated memory
|
||||
for a small contained value[.](#2.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
Such small-object optimization can only be applied to a type T for which is_nothrow_move_constructible_v<T> is true[.](#2.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
351
cppdraft/func/wrap/copy/ctor.md
Normal file
351
cppdraft/func/wrap/copy/ctor.md
Normal file
@@ -0,0 +1,351 @@
|
||||
[func.wrap.copy.ctor]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.copy.ctor)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#copy.ctor)
|
||||
|
||||
#### 22.10.17.5 Copyable wrapper [[func.wrap.copy]](func.wrap.copy#ctor)
|
||||
|
||||
#### 22.10.17.5.3 Constructors, assignments, and destructor [func.wrap.copy.ctor]
|
||||
|
||||
[ð](#:copyable_function::is-callable-from)
|
||||
|
||||
`template<class VT>
|
||||
static constexpr bool is-callable-from = see below;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14573)
|
||||
|
||||
If *noex* is true,*is-callable-from*<VT> is equal to:is_nothrow_invocable_r_v<R, VT cv *ref*, ArgTypes...> && is_nothrow_invocable_r_v<R, VT *inv-quals*, ArgTypes...>
|
||||
|
||||
Otherwise, *is-callable-from*<VT> is equal to:is_invocable_r_v<R, VT cv *ref*, ArgTypes...> && is_invocable_r_v<R, VT *inv-quals*, ArgTypes...>
|
||||
|
||||
[ð](#lib:copyable_function,constructor)
|
||||
|
||||
`copyable_function() noexcept;
|
||||
copyable_function(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14594)
|
||||
|
||||
*Postconditions*: *this has no target object[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:copyable_function,constructor_)
|
||||
|
||||
`copyable_function(const copyable_function& f);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14605)
|
||||
|
||||
*Postconditions*: *this has no target object if f had no target object[.](#3.sentence-1)
|
||||
|
||||
Otherwise, the target object of *this is a copy of the target object of f[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14611)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#4.sentence-1)
|
||||
|
||||
May throw bad_alloc[.](#4.sentence-2)
|
||||
|
||||
[ð](#lib:copyable_function,constructor__)
|
||||
|
||||
`copyable_function(copyable_function&& f) noexcept;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14623)
|
||||
|
||||
*Postconditions*: The target object of *this is
|
||||
the target object f had before construction, andf is in a valid state with an unspecified value[.](#5.sentence-1)
|
||||
|
||||
[ð](#lib:copyable_function,constructor___)
|
||||
|
||||
`template<class F> copyable_function(F&& f);
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14636)
|
||||
|
||||
Let VT be decay_t<F>[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14639)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(7.1)](#7.1)
|
||||
|
||||
remove_cvref_t<F> is not the same type as copyable_function, and
|
||||
|
||||
- [(7.2)](#7.2)
|
||||
|
||||
remove_cvref_t<F> is not a specialization of in_place_type_t, and
|
||||
|
||||
- [(7.3)](#7.3)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14650)
|
||||
|
||||
*Mandates*:
|
||||
|
||||
- [(8.1)](#8.1)
|
||||
|
||||
is_constructible_v<VT, F> is true, and
|
||||
|
||||
- [(8.2)](#8.2)
|
||||
|
||||
is_copy_constructible_v<VT> is true[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14659)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14664)
|
||||
|
||||
*Postconditions*: *this has no target object if any of the following hold:
|
||||
|
||||
- [(10.1)](#10.1)
|
||||
|
||||
f is a null function pointer value, or
|
||||
|
||||
- [(10.2)](#10.2)
|
||||
|
||||
f is a null member pointer value, or
|
||||
|
||||
- [(10.3)](#10.3)
|
||||
|
||||
remove_cvref_t<F> is a specialization of
|
||||
the copyable_function class template,
|
||||
and f has no target object[.](#10.sentence-1)
|
||||
|
||||
Otherwise, *this has a target object of type VT direct-non-list-initialized with std::forward<F>(f)[.](#10.sentence-2)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14680)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#11.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a function pointer or a specialization of reference_wrapper[.](#11.sentence-2)
|
||||
|
||||
[ð](#lib:copyable_function,constructor____)
|
||||
|
||||
`template<class T, class... Args>
|
||||
explicit copyable_function(in_place_type_t<T>, Args&&... args);
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14694)
|
||||
|
||||
Let VT be decay_t<T>[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14697)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(13.1)](#13.1)
|
||||
|
||||
is_constructible_v<VT, Args...> is true, and
|
||||
|
||||
- [(13.2)](#13.2)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14706)
|
||||
|
||||
*Mandates*:
|
||||
|
||||
- [(14.1)](#14.1)
|
||||
|
||||
VT is the same type as T, and
|
||||
|
||||
- [(14.2)](#14.2)
|
||||
|
||||
is_copy_constructible_v<VT> is true[.](#14.sentence-1)
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14715)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#15.sentence-1)
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14720)
|
||||
|
||||
*Postconditions*: *this has a target object of type VT direct-non-list-initialized with std::forward<Args>(args)...[.](#16.sentence-1)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14725)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#17.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a pointer or a specialization of reference_wrapper[.](#17.sentence-2)
|
||||
|
||||
[ð](#lib:copyable_function,constructor_____)
|
||||
|
||||
`template<class T, class U, class... Args>
|
||||
explicit copyable_function(in_place_type_t<T>, initializer_list<U> ilist, Args&&... args);
|
||||
`
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14739)
|
||||
|
||||
Let VT be decay_t<T>[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14742)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(19.1)](#19.1)
|
||||
|
||||
is_constructible_v<VT, initializer_list<U>&, Args...> istrue, and
|
||||
|
||||
- [(19.2)](#19.2)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#19.sentence-1)
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14752)
|
||||
|
||||
*Mandates*:
|
||||
|
||||
- [(20.1)](#20.1)
|
||||
|
||||
VT is the same type as T, and
|
||||
|
||||
- [(20.2)](#20.2)
|
||||
|
||||
is_copy_constructible_v<VT> is true[.](#20.sentence-1)
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14761)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#21.sentence-1)
|
||||
|
||||
[22](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14766)
|
||||
|
||||
*Postconditions*: *this has a target object of type VT direct-non-list-initialized withilist, std::forward<Args>(args)...[.](#22.sentence-1)
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14772)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#23.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a pointer or a specialization of reference_wrapper[.](#23.sentence-2)
|
||||
|
||||
[ð](#lib:operator=,copyable_function)
|
||||
|
||||
`copyable_function& operator=(const copyable_function& f);
|
||||
`
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14785)
|
||||
|
||||
*Effects*: Equivalent to: copyable_function(f).swap(*this);
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14789)
|
||||
|
||||
*Returns*: *this[.](#25.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,copyable_function_)
|
||||
|
||||
`copyable_function& operator=(copyable_function&& f);
|
||||
`
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14800)
|
||||
|
||||
*Effects*: Equivalent to: copyable_function(std::move(f)).swap(*this);
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14804)
|
||||
|
||||
*Returns*: *this[.](#27.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,copyable_function__)
|
||||
|
||||
`copyable_function& operator=(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[28](#28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14815)
|
||||
|
||||
*Effects*: Destroys the target object of *this, if any[.](#28.sentence-1)
|
||||
|
||||
[29](#29)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14819)
|
||||
|
||||
*Returns*: *this[.](#29.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,copyable_function___)
|
||||
|
||||
`template<class F> copyable_function& operator=(F&& f);
|
||||
`
|
||||
|
||||
[30](#30)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14830)
|
||||
|
||||
*Effects*: Equivalent to: copyable_function(std::forward<F>(f)).swap(*this);
|
||||
|
||||
[31](#31)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14834)
|
||||
|
||||
*Returns*: *this[.](#31.sentence-1)
|
||||
|
||||
[ð](#lib:copyable_function,destructor)
|
||||
|
||||
`~copyable_function();
|
||||
`
|
||||
|
||||
[32](#32)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14845)
|
||||
|
||||
*Effects*: Destroys the target object of *this, if any[.](#32.sentence-1)
|
||||
45
cppdraft/func/wrap/copy/general.md
Normal file
45
cppdraft/func/wrap/copy/general.md
Normal file
@@ -0,0 +1,45 @@
|
||||
[func.wrap.copy.general]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.copy.general)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#copy.general)
|
||||
|
||||
#### 22.10.17.5 Copyable wrapper [[func.wrap.copy]](func.wrap.copy#general)
|
||||
|
||||
#### 22.10.17.5.1 General [func.wrap.copy.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14482)
|
||||
|
||||
The header provides partial specializations of copyable_function for each combination of the possible replacements
|
||||
of the placeholders cv, *ref*, and *noex* where
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
cv is either const or empty,
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
*ref* is either &, &&, or empty, and
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
*noex* is either true or false[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14495)
|
||||
|
||||
For each of the possible combinations of the placeholders mentioned above,
|
||||
there is a placeholder *inv-quals* defined as follows:
|
||||
|
||||
- [(2.1)](#2.1)
|
||||
|
||||
If *ref* is empty, let *inv-quals* be cv&,
|
||||
|
||||
- [(2.2)](#2.2)
|
||||
|
||||
otherwise, let *inv-quals* be cv *ref*[.](#2.sentence-1)
|
||||
39
cppdraft/func/wrap/copy/inv.md
Normal file
39
cppdraft/func/wrap/copy/inv.md
Normal file
@@ -0,0 +1,39 @@
|
||||
[func.wrap.copy.inv]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.copy.inv)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#copy.inv)
|
||||
|
||||
#### 22.10.17.5 Copyable wrapper [[func.wrap.copy]](func.wrap.copy#inv)
|
||||
|
||||
#### 22.10.17.5.4 Invocation [func.wrap.copy.inv]
|
||||
|
||||
[ð](#lib:operator_bool,copyable_function)
|
||||
|
||||
`explicit operator bool() const noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14858)
|
||||
|
||||
*Returns*: true if *this has a target object, otherwise false[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:operator(),copyable_function)
|
||||
|
||||
`R operator()(ArgTypes... args) cv ref noexcept(noex);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14869)
|
||||
|
||||
*Preconditions*: *this has a target object[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14873)
|
||||
|
||||
*Effects*: Equivalent to:return *INVOKE*<R>(static_cast<F *inv-quals*>(f), std::forward<ArgTypes>(args)...); where f is an lvalue designating the target object of *this andF is the type of f[.](#3.sentence-1)
|
||||
44
cppdraft/func/wrap/copy/util.md
Normal file
44
cppdraft/func/wrap/copy/util.md
Normal file
@@ -0,0 +1,44 @@
|
||||
[func.wrap.copy.util]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.copy.util)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#copy.util)
|
||||
|
||||
#### 22.10.17.5 Copyable wrapper [[func.wrap.copy]](func.wrap.copy#util)
|
||||
|
||||
#### 22.10.17.5.5 Utility [func.wrap.copy.util]
|
||||
|
||||
[ð](#lib:swap,copyable_function)
|
||||
|
||||
`void swap(copyable_function& other) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14891)
|
||||
|
||||
*Effects*: Exchanges the target objects of *this and other[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:swap,copyable_function_)
|
||||
|
||||
`friend void swap(copyable_function& f1, copyable_function& f2) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14902)
|
||||
|
||||
*Effects*: Equivalent to f1.swap(f2)[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:operator==,copyable_function)
|
||||
|
||||
`friend bool operator==(const copyable_function& f, nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14913)
|
||||
|
||||
*Returns*: true if f has no target object, otherwise false[.](#3.sentence-1)
|
||||
457
cppdraft/func/wrap/func.md
Normal file
457
cppdraft/func/wrap/func.md
Normal file
@@ -0,0 +1,457 @@
|
||||
[func.wrap.func]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.func)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#func)
|
||||
|
||||
#### 22.10.17.3 Class template function [func.wrap.func]
|
||||
|
||||
#### [22.10.17.3.1](#general) General [[func.wrap.func.general]](func.wrap.func.general)
|
||||
|
||||
[ð](#lib:result_type,function)
|
||||
|
||||
namespace std {template<class R, class... ArgTypes>class function<R(ArgTypes...)> {public:using result_type = R; // [[func.wrap.func.con]](#con "22.10.17.3.2 Constructors and destructor"), construct/copy/destroy function() noexcept;
|
||||
function(nullptr_t) noexcept;
|
||||
function(const function&);
|
||||
function(function&&) noexcept; template<class F> function(F&&);
|
||||
|
||||
function& operator=(const function&);
|
||||
function& operator=(function&&);
|
||||
function& operator=(nullptr_t) noexcept; template<class F> function& operator=(F&&); template<class F> function& operator=(reference_wrapper<F>) noexcept; ~function(); // [[func.wrap.func.mod]](#mod "22.10.17.3.3 Modifiers"), function modifiersvoid swap(function&) noexcept; // [[func.wrap.func.cap]](#cap "22.10.17.3.4 Capacity"), function capacityexplicit operator bool() const noexcept; // [[func.wrap.func.inv]](#inv "22.10.17.3.5 Invocation"), function invocation R operator()(ArgTypes...) const; // [[func.wrap.func.targ]](#targ "22.10.17.3.6 Target access"), function target accessconst type_info& target_type() const noexcept; template<class T> T* target() noexcept; template<class T> const T* target() const noexcept; }; template<class R, class... ArgTypes> function(R(*)(ArgTypes...)) -> function<R(ArgTypes...)>; template<class F> function(F) -> function<*see below*>;}
|
||||
|
||||
[1](#general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13701)
|
||||
|
||||
The function class template provides polymorphic wrappers that
|
||||
generalize the notion of a function pointer[.](#general-1.sentence-1)
|
||||
|
||||
Wrappers can store, copy,
|
||||
and call arbitrary callable objects ([[func.def]](func.def "22.10.3 Definitions")), given a call
|
||||
signature ([[func.def]](func.def "22.10.3 Definitions"))[.](#general-1.sentence-2)
|
||||
|
||||
[2](#general-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13707)
|
||||
|
||||
The function class template is a call
|
||||
wrapper ([[func.def]](func.def "22.10.3 Definitions")) whose call signature ([[func.def]](func.def "22.10.3 Definitions"))
|
||||
is R(ArgTypes...)[.](#general-2.sentence-1)
|
||||
|
||||
[3](#general-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13712)
|
||||
|
||||
[*Note [1](#general-note-1)*:
|
||||
|
||||
The types deduced by the deduction guides for function might change in future revisions of C++[.](#general-3.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
|
||||
#### [22.10.17.3.2](#con) Constructors and destructor [[func.wrap.func.con]](func.wrap.func.con)
|
||||
|
||||
[ð](#lib:function,constructor)
|
||||
|
||||
`function() noexcept;
|
||||
`
|
||||
|
||||
[1](#con-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13726)
|
||||
|
||||
*Postconditions*: !*this[.](#con-1.sentence-1)
|
||||
|
||||
[ð](#lib:function,constructor_)
|
||||
|
||||
`function(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[2](#con-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13737)
|
||||
|
||||
*Postconditions*: !*this[.](#con-2.sentence-1)
|
||||
|
||||
[ð](#lib:function,constructor__)
|
||||
|
||||
`function(const function& f);
|
||||
`
|
||||
|
||||
[3](#con-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13748)
|
||||
|
||||
*Postconditions*: !*this if !f; otherwise,
|
||||
the target object of *this is a copy of the target object of f[.](#con-3.sentence-1)
|
||||
|
||||
[4](#con-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13753)
|
||||
|
||||
*Throws*: Nothing if f's target is
|
||||
a specialization of reference_wrapper or
|
||||
a function pointer[.](#con-4.sentence-1)
|
||||
|
||||
Otherwise, may throw bad_alloc or any exception thrown by the copy constructor of the stored callable object[.](#con-4.sentence-2)
|
||||
|
||||
[5](#con-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13760)
|
||||
|
||||
*Recommended practice*: Implementations should avoid the use of
|
||||
dynamically allocated memory for small callable objects, for example, wheref's target is an object holding only a pointer or reference
|
||||
to an object and a member function pointer[.](#con-5.sentence-1)
|
||||
|
||||
[ð](#lib:function,constructor___)
|
||||
|
||||
`function(function&& f) noexcept;
|
||||
`
|
||||
|
||||
[6](#con-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13774)
|
||||
|
||||
*Postconditions*: If !f, *this has no target;
|
||||
otherwise, the target of *this is equivalent to
|
||||
the target of f before the construction, andf is in a valid state with an unspecified value[.](#con-6.sentence-1)
|
||||
|
||||
[7](#con-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13781)
|
||||
|
||||
*Recommended practice*: Implementations should avoid the use of
|
||||
dynamically allocated memory for small callable objects, for example,
|
||||
where f's target is an object holding only a pointer or reference
|
||||
to an object and a member function pointer[.](#con-7.sentence-1)
|
||||
|
||||
[ð](#lib:function,constructor____)
|
||||
|
||||
`template<class F> function(F&& f);
|
||||
`
|
||||
|
||||
[8](#con-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13795)
|
||||
|
||||
Let FD be decay_t<F>[.](#con-8.sentence-1)
|
||||
|
||||
[9](#con-9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13798)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(9.1)](#con-9.1)
|
||||
|
||||
is_same_v<remove_cvref_t<F>, function> is false, and
|
||||
|
||||
- [(9.2)](#con-9.2)
|
||||
|
||||
is_invocable_r_v<R, FD&, ArgTypes...> is true[.](#con-9.sentence-1)
|
||||
|
||||
[10](#con-10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13807)
|
||||
|
||||
*Mandates*:
|
||||
|
||||
- [(10.1)](#con-10.1)
|
||||
|
||||
is_copy_constructible_v<FD> is true, and
|
||||
|
||||
- [(10.2)](#con-10.2)
|
||||
|
||||
is_constructible_v<FD, F> is true[.](#con-10.sentence-1)
|
||||
|
||||
[11](#con-11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13816)
|
||||
|
||||
*Preconditions*: FD meets the [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#con-11.sentence-1)
|
||||
|
||||
[12](#con-12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13820)
|
||||
|
||||
*Postconditions*: !*this is true if any of the following hold:
|
||||
|
||||
- [(12.1)](#con-12.1)
|
||||
|
||||
f is a null function pointer value[.](#con-12.1.sentence-1)
|
||||
|
||||
- [(12.2)](#con-12.2)
|
||||
|
||||
f is a null member pointer value[.](#con-12.2.sentence-1)
|
||||
|
||||
- [(12.3)](#con-12.3)
|
||||
|
||||
remove_cvref_t<F> is
|
||||
a specialization of the function class template, and!f is true[.](#con-12.3.sentence-1)
|
||||
|
||||
[13](#con-13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13831)
|
||||
|
||||
Otherwise, *this has a target object of type FD direct-non-list-initialized with std::forward<F>(f)[.](#con-13.sentence-1)
|
||||
|
||||
[14](#con-14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13835)
|
||||
|
||||
*Throws*: Nothing if FD is
|
||||
a specialization of reference_wrapper or
|
||||
a function pointer type[.](#con-14.sentence-1)
|
||||
|
||||
Otherwise, may throw bad_alloc or
|
||||
any exception thrown by the initialization of the target object[.](#con-14.sentence-2)
|
||||
|
||||
[15](#con-15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13843)
|
||||
|
||||
*Recommended practice*: Implementations should avoid the use of
|
||||
dynamically allocated memory for small callable objects, for example,
|
||||
where f refers to an object holding only a pointer or
|
||||
reference to an object and a member function pointer[.](#con-15.sentence-1)
|
||||
|
||||
[ð](#con-itemdecl:6)
|
||||
|
||||
`template<class F> function(F) -> function<see below>;
|
||||
`
|
||||
|
||||
[16](#con-16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13857)
|
||||
|
||||
*Constraints*: &F::operator() is well-formed when treated as an unevaluated operand and either
|
||||
|
||||
- [(16.1)](#con-16.1)
|
||||
|
||||
F::operator() is a non-static member function anddecltype(&F::operator()) is either of the formR(G::*)(A...) cv &opt noexceptopt or of the formR(*)(G, A...) noexceptopt for a type G, or
|
||||
|
||||
- [(16.2)](#con-16.2)
|
||||
|
||||
F::operator() is a static member function anddecltype(&F::operator()) is of the formR(*)(A...) noexceptopt[.](#con-16.sentence-1)
|
||||
|
||||
[17](#con-17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13874)
|
||||
|
||||
*Remarks*: The deduced type is function<R(A...)>[.](#con-17.sentence-1)
|
||||
|
||||
[18](#con-18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13878)
|
||||
|
||||
[*Example [1](#con-example-1)*: void f() {int i{5};
|
||||
function g = [&](double) { return i; }; // deduces function<int(double)>} â *end example*]
|
||||
|
||||
[ð](#lib:operator=,function)
|
||||
|
||||
`function& operator=(const function& f);
|
||||
`
|
||||
|
||||
[19](#con-19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13895)
|
||||
|
||||
*Effects*: As if by function(f).swap(*this);
|
||||
|
||||
[20](#con-20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13899)
|
||||
|
||||
*Returns*: *this[.](#con-20.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,function_)
|
||||
|
||||
`function& operator=(function&& f);
|
||||
`
|
||||
|
||||
[21](#con-21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13910)
|
||||
|
||||
*Effects*: Replaces the target of *this with the target of f[.](#con-21.sentence-1)
|
||||
|
||||
[22](#con-22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13915)
|
||||
|
||||
*Returns*: *this[.](#con-22.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,function__)
|
||||
|
||||
`function& operator=(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[23](#con-23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13926)
|
||||
|
||||
*Effects*: If *this != nullptr, destroys the target of this[.](#con-23.sentence-1)
|
||||
|
||||
[24](#con-24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13930)
|
||||
|
||||
*Postconditions*: !(*this)[.](#con-24.sentence-1)
|
||||
|
||||
[25](#con-25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13934)
|
||||
|
||||
*Returns*: *this[.](#con-25.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,function___)
|
||||
|
||||
`template<class F> function& operator=(F&& f);
|
||||
`
|
||||
|
||||
[26](#con-26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13945)
|
||||
|
||||
*Constraints*: is_invocable_r_v<R, decay_t<F>&, ArgTypes...> is true[.](#con-26.sentence-1)
|
||||
|
||||
[27](#con-27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13949)
|
||||
|
||||
*Effects*: As if by: function(std::forward<F>(f)).swap(*this);
|
||||
|
||||
[28](#con-28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13953)
|
||||
|
||||
*Returns*: *this[.](#con-28.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,function____)
|
||||
|
||||
`template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
||||
`
|
||||
|
||||
[29](#con-29)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13964)
|
||||
|
||||
*Effects*: As if by: function(f).swap(*this);
|
||||
|
||||
[30](#con-30)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13968)
|
||||
|
||||
*Returns*: *this[.](#con-30.sentence-1)
|
||||
|
||||
[ð](#lib:function,destructor)
|
||||
|
||||
`~function();
|
||||
`
|
||||
|
||||
[31](#con-31)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13979)
|
||||
|
||||
*Effects*: If *this != nullptr, destroys the target of this[.](#con-31.sentence-1)
|
||||
|
||||
#### [22.10.17.3.3](#mod) Modifiers [[func.wrap.func.mod]](func.wrap.func.mod)
|
||||
|
||||
[ð](#lib:swap,function)
|
||||
|
||||
`void swap(function& other) noexcept;
|
||||
`
|
||||
|
||||
[1](#mod-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13992)
|
||||
|
||||
*Effects*: Interchanges the target objects of *this and other[.](#mod-1.sentence-1)
|
||||
|
||||
#### [22.10.17.3.4](#cap) Capacity [[func.wrap.func.cap]](func.wrap.func.cap)
|
||||
|
||||
[ð](#lib:operator_bool,function)
|
||||
|
||||
`explicit operator bool() const noexcept;
|
||||
`
|
||||
|
||||
[1](#cap-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14005)
|
||||
|
||||
*Returns*: true if *this has a target, otherwise false[.](#cap-1.sentence-1)
|
||||
|
||||
#### [22.10.17.3.5](#inv) Invocation [[func.wrap.func.inv]](func.wrap.func.inv)
|
||||
|
||||
[ð](#lib:function,invocation)
|
||||
|
||||
`R operator()(ArgTypes... args) const;
|
||||
`
|
||||
|
||||
[1](#inv-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14019)
|
||||
|
||||
*Returns*: *INVOKE*<R>(f, std::forward<ArgTypes>(args)...) ([[func.require]](func.require "22.10.4 Requirements")),
|
||||
where f is the target object ([[func.def]](func.def "22.10.3 Definitions")) of *this[.](#inv-1.sentence-1)
|
||||
|
||||
[2](#inv-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14024)
|
||||
|
||||
*Throws*: bad_function_call if !*this; otherwise, any
|
||||
exception thrown by the target object[.](#inv-2.sentence-1)
|
||||
|
||||
#### [22.10.17.3.6](#targ) Target access [[func.wrap.func.targ]](func.wrap.func.targ)
|
||||
|
||||
[ð](#lib:target_type,function)
|
||||
|
||||
`const type_info& target_type() const noexcept;
|
||||
`
|
||||
|
||||
[1](#targ-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14038)
|
||||
|
||||
*Returns*: If *this has a target of type T, typeid(T); otherwise, typeid(void)[.](#targ-1.sentence-1)
|
||||
|
||||
[ð](#lib:target,function)
|
||||
|
||||
`template<class T> T* target() noexcept;
|
||||
template<class T> const T* target() const noexcept;
|
||||
`
|
||||
|
||||
[2](#targ-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14051)
|
||||
|
||||
*Returns*: If target_type() == typeid(T) a pointer to the stored function target; otherwise a null pointer[.](#targ-2.sentence-1)
|
||||
|
||||
#### [22.10.17.3.7](#nullptr) Null pointer comparison operator functions [[func.wrap.func.nullptr]](func.wrap.func.nullptr)
|
||||
|
||||
[ð](#lib:operator==,function)
|
||||
|
||||
`template<class R, class... ArgTypes>
|
||||
bool operator==(const function<R(ArgTypes...)>& f, nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[1](#nullptr-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14066)
|
||||
|
||||
*Returns*: !f[.](#nullptr-1.sentence-1)
|
||||
|
||||
#### [22.10.17.3.8](#alg) Specialized algorithms [[func.wrap.func.alg]](func.wrap.func.alg)
|
||||
|
||||
[ð](#lib:swap,function_)
|
||||
|
||||
`template<class R, class... ArgTypes>
|
||||
void swap(function<R(ArgTypes...)>& f1, function<R(ArgTypes...)>& f2) noexcept;
|
||||
`
|
||||
|
||||
[1](#alg-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14080)
|
||||
|
||||
*Effects*: As if by: f1.swap(f2);
|
||||
23
cppdraft/func/wrap/func/alg.md
Normal file
23
cppdraft/func/wrap/func/alg.md
Normal file
@@ -0,0 +1,23 @@
|
||||
[func.wrap.func.alg]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.func.alg)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#func.alg)
|
||||
|
||||
#### 22.10.17.3 Class template function [[func.wrap.func]](func.wrap.func#alg)
|
||||
|
||||
#### 22.10.17.3.8 Specialized algorithms [func.wrap.func.alg]
|
||||
|
||||
[ð](#lib:swap,function)
|
||||
|
||||
`template<class R, class... ArgTypes>
|
||||
void swap(function<R(ArgTypes...)>& f1, function<R(ArgTypes...)>& f2) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14080)
|
||||
|
||||
*Effects*: As if by: f1.swap(f2);
|
||||
22
cppdraft/func/wrap/func/cap.md
Normal file
22
cppdraft/func/wrap/func/cap.md
Normal file
@@ -0,0 +1,22 @@
|
||||
[func.wrap.func.cap]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.func.cap)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#func.cap)
|
||||
|
||||
#### 22.10.17.3 Class template function [[func.wrap.func]](func.wrap.func#cap)
|
||||
|
||||
#### 22.10.17.3.4 Capacity [func.wrap.func.cap]
|
||||
|
||||
[ð](#lib:operator_bool,function)
|
||||
|
||||
`explicit operator bool() const noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14005)
|
||||
|
||||
*Returns*: true if *this has a target, otherwise false[.](#1.sentence-1)
|
||||
315
cppdraft/func/wrap/func/con.md
Normal file
315
cppdraft/func/wrap/func/con.md
Normal file
@@ -0,0 +1,315 @@
|
||||
[func.wrap.func.con]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.func.con)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#func.con)
|
||||
|
||||
#### 22.10.17.3 Class template function [[func.wrap.func]](func.wrap.func#con)
|
||||
|
||||
#### 22.10.17.3.2 Constructors and destructor [func.wrap.func.con]
|
||||
|
||||
[ð](#lib:function,constructor)
|
||||
|
||||
`function() noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13726)
|
||||
|
||||
*Postconditions*: !*this[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:function,constructor_)
|
||||
|
||||
`function(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13737)
|
||||
|
||||
*Postconditions*: !*this[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:function,constructor__)
|
||||
|
||||
`function(const function& f);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13748)
|
||||
|
||||
*Postconditions*: !*this if !f; otherwise,
|
||||
the target object of *this is a copy of the target object of f[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13753)
|
||||
|
||||
*Throws*: Nothing if f's target is
|
||||
a specialization of reference_wrapper or
|
||||
a function pointer[.](#4.sentence-1)
|
||||
|
||||
Otherwise, may throw bad_alloc or any exception thrown by the copy constructor of the stored callable object[.](#4.sentence-2)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13760)
|
||||
|
||||
*Recommended practice*: Implementations should avoid the use of
|
||||
dynamically allocated memory for small callable objects, for example, wheref's target is an object holding only a pointer or reference
|
||||
to an object and a member function pointer[.](#5.sentence-1)
|
||||
|
||||
[ð](#lib:function,constructor___)
|
||||
|
||||
`function(function&& f) noexcept;
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13774)
|
||||
|
||||
*Postconditions*: If !f, *this has no target;
|
||||
otherwise, the target of *this is equivalent to
|
||||
the target of f before the construction, andf is in a valid state with an unspecified value[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13781)
|
||||
|
||||
*Recommended practice*: Implementations should avoid the use of
|
||||
dynamically allocated memory for small callable objects, for example,
|
||||
where f's target is an object holding only a pointer or reference
|
||||
to an object and a member function pointer[.](#7.sentence-1)
|
||||
|
||||
[ð](#lib:function,constructor____)
|
||||
|
||||
`template<class F> function(F&& f);
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13795)
|
||||
|
||||
Let FD be decay_t<F>[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13798)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(9.1)](#9.1)
|
||||
|
||||
is_same_v<remove_cvref_t<F>, function> is false, and
|
||||
|
||||
- [(9.2)](#9.2)
|
||||
|
||||
is_invocable_r_v<R, FD&, ArgTypes...> is true[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13807)
|
||||
|
||||
*Mandates*:
|
||||
|
||||
- [(10.1)](#10.1)
|
||||
|
||||
is_copy_constructible_v<FD> is true, and
|
||||
|
||||
- [(10.2)](#10.2)
|
||||
|
||||
is_constructible_v<FD, F> is true[.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13816)
|
||||
|
||||
*Preconditions*: FD meets the [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13820)
|
||||
|
||||
*Postconditions*: !*this is true if any of the following hold:
|
||||
|
||||
- [(12.1)](#12.1)
|
||||
|
||||
f is a null function pointer value[.](#12.1.sentence-1)
|
||||
|
||||
- [(12.2)](#12.2)
|
||||
|
||||
f is a null member pointer value[.](#12.2.sentence-1)
|
||||
|
||||
- [(12.3)](#12.3)
|
||||
|
||||
remove_cvref_t<F> is
|
||||
a specialization of the function class template, and!f is true[.](#12.3.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13831)
|
||||
|
||||
Otherwise, *this has a target object of type FD direct-non-list-initialized with std::forward<F>(f)[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13835)
|
||||
|
||||
*Throws*: Nothing if FD is
|
||||
a specialization of reference_wrapper or
|
||||
a function pointer type[.](#14.sentence-1)
|
||||
|
||||
Otherwise, may throw bad_alloc or
|
||||
any exception thrown by the initialization of the target object[.](#14.sentence-2)
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13843)
|
||||
|
||||
*Recommended practice*: Implementations should avoid the use of
|
||||
dynamically allocated memory for small callable objects, for example,
|
||||
where f refers to an object holding only a pointer or
|
||||
reference to an object and a member function pointer[.](#15.sentence-1)
|
||||
|
||||
[ð](#itemdecl:6)
|
||||
|
||||
`template<class F> function(F) -> function<see below>;
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13857)
|
||||
|
||||
*Constraints*: &F::operator() is well-formed when treated as an unevaluated operand and either
|
||||
|
||||
- [(16.1)](#16.1)
|
||||
|
||||
F::operator() is a non-static member function anddecltype(&F::operator()) is either of the formR(G::*)(A...) cv &opt noexceptopt or of the formR(*)(G, A...) noexceptopt for a type G, or
|
||||
|
||||
- [(16.2)](#16.2)
|
||||
|
||||
F::operator() is a static member function anddecltype(&F::operator()) is of the formR(*)(A...) noexceptopt[.](#16.sentence-1)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13874)
|
||||
|
||||
*Remarks*: The deduced type is function<R(A...)>[.](#17.sentence-1)
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13878)
|
||||
|
||||
[*Example [1](#example-1)*: void f() {int i{5};
|
||||
function g = [&](double) { return i; }; // deduces function<int(double)>} â *end example*]
|
||||
|
||||
[ð](#lib:operator=,function)
|
||||
|
||||
`function& operator=(const function& f);
|
||||
`
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13895)
|
||||
|
||||
*Effects*: As if by function(f).swap(*this);
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13899)
|
||||
|
||||
*Returns*: *this[.](#20.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,function_)
|
||||
|
||||
`function& operator=(function&& f);
|
||||
`
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13910)
|
||||
|
||||
*Effects*: Replaces the target of *this with the target of f[.](#21.sentence-1)
|
||||
|
||||
[22](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13915)
|
||||
|
||||
*Returns*: *this[.](#22.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,function__)
|
||||
|
||||
`function& operator=(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13926)
|
||||
|
||||
*Effects*: If *this != nullptr, destroys the target of this[.](#23.sentence-1)
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13930)
|
||||
|
||||
*Postconditions*: !(*this)[.](#24.sentence-1)
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13934)
|
||||
|
||||
*Returns*: *this[.](#25.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,function___)
|
||||
|
||||
`template<class F> function& operator=(F&& f);
|
||||
`
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13945)
|
||||
|
||||
*Constraints*: is_invocable_r_v<R, decay_t<F>&, ArgTypes...> is true[.](#26.sentence-1)
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13949)
|
||||
|
||||
*Effects*: As if by: function(std::forward<F>(f)).swap(*this);
|
||||
|
||||
[28](#28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13953)
|
||||
|
||||
*Returns*: *this[.](#28.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,function____)
|
||||
|
||||
`template<class F> function& operator=(reference_wrapper<F> f) noexcept;
|
||||
`
|
||||
|
||||
[29](#29)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13964)
|
||||
|
||||
*Effects*: As if by: function(f).swap(*this);
|
||||
|
||||
[30](#30)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13968)
|
||||
|
||||
*Returns*: *this[.](#30.sentence-1)
|
||||
|
||||
[ð](#lib:function,destructor)
|
||||
|
||||
`~function();
|
||||
`
|
||||
|
||||
[31](#31)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13979)
|
||||
|
||||
*Effects*: If *this != nullptr, destroys the target of this[.](#31.sentence-1)
|
||||
51
cppdraft/func/wrap/func/general.md
Normal file
51
cppdraft/func/wrap/func/general.md
Normal file
@@ -0,0 +1,51 @@
|
||||
[func.wrap.func.general]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.func.general)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#func.general)
|
||||
|
||||
#### 22.10.17.3 Class template function [[func.wrap.func]](func.wrap.func#general)
|
||||
|
||||
#### 22.10.17.3.1 General [func.wrap.func.general]
|
||||
|
||||
[ð](#lib:result_type,function)
|
||||
|
||||
namespace std {template<class R, class... ArgTypes>class function<R(ArgTypes...)> {public:using result_type = R; // [[func.wrap.func.con]](func.wrap.func.con "22.10.17.3.2 Constructors and destructor"), construct/copy/destroy function() noexcept;
|
||||
function(nullptr_t) noexcept;
|
||||
function(const function&);
|
||||
function(function&&) noexcept; template<class F> function(F&&);
|
||||
|
||||
function& operator=(const function&);
|
||||
function& operator=(function&&);
|
||||
function& operator=(nullptr_t) noexcept; template<class F> function& operator=(F&&); template<class F> function& operator=(reference_wrapper<F>) noexcept; ~function(); // [[func.wrap.func.mod]](func.wrap.func.mod "22.10.17.3.3 Modifiers"), function modifiersvoid swap(function&) noexcept; // [[func.wrap.func.cap]](func.wrap.func.cap "22.10.17.3.4 Capacity"), function capacityexplicit operator bool() const noexcept; // [[func.wrap.func.inv]](func.wrap.func.inv "22.10.17.3.5 Invocation"), function invocation R operator()(ArgTypes...) const; // [[func.wrap.func.targ]](func.wrap.func.targ "22.10.17.3.6 Target access"), function target accessconst type_info& target_type() const noexcept; template<class T> T* target() noexcept; template<class T> const T* target() const noexcept; }; template<class R, class... ArgTypes> function(R(*)(ArgTypes...)) -> function<R(ArgTypes...)>; template<class F> function(F) -> function<*see below*>;}
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13701)
|
||||
|
||||
The function class template provides polymorphic wrappers that
|
||||
generalize the notion of a function pointer[.](#1.sentence-1)
|
||||
|
||||
Wrappers can store, copy,
|
||||
and call arbitrary callable objects ([[func.def]](func.def "22.10.3 Definitions")), given a call
|
||||
signature ([[func.def]](func.def "22.10.3 Definitions"))[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13707)
|
||||
|
||||
The function class template is a call
|
||||
wrapper ([[func.def]](func.def "22.10.3 Definitions")) whose call signature ([[func.def]](func.def "22.10.3 Definitions"))
|
||||
is R(ArgTypes...)[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13712)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The types deduced by the deduction guides for function might change in future revisions of C++[.](#3.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
30
cppdraft/func/wrap/func/inv.md
Normal file
30
cppdraft/func/wrap/func/inv.md
Normal file
@@ -0,0 +1,30 @@
|
||||
[func.wrap.func.inv]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.func.inv)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#func.inv)
|
||||
|
||||
#### 22.10.17.3 Class template function [[func.wrap.func]](func.wrap.func#inv)
|
||||
|
||||
#### 22.10.17.3.5 Invocation [func.wrap.func.inv]
|
||||
|
||||
[ð](#lib:function,invocation)
|
||||
|
||||
`R operator()(ArgTypes... args) const;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14019)
|
||||
|
||||
*Returns*: *INVOKE*<R>(f, std::forward<ArgTypes>(args)...) ([[func.require]](func.require "22.10.4 Requirements")),
|
||||
where f is the target object ([[func.def]](func.def "22.10.3 Definitions")) of *this[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14024)
|
||||
|
||||
*Throws*: bad_function_call if !*this; otherwise, any
|
||||
exception thrown by the target object[.](#2.sentence-1)
|
||||
22
cppdraft/func/wrap/func/mod.md
Normal file
22
cppdraft/func/wrap/func/mod.md
Normal file
@@ -0,0 +1,22 @@
|
||||
[func.wrap.func.mod]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.func.mod)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#func.mod)
|
||||
|
||||
#### 22.10.17.3 Class template function [[func.wrap.func]](func.wrap.func#mod)
|
||||
|
||||
#### 22.10.17.3.3 Modifiers [func.wrap.func.mod]
|
||||
|
||||
[ð](#lib:swap,function)
|
||||
|
||||
`void swap(function& other) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13992)
|
||||
|
||||
*Effects*: Interchanges the target objects of *this and other[.](#1.sentence-1)
|
||||
23
cppdraft/func/wrap/func/nullptr.md
Normal file
23
cppdraft/func/wrap/func/nullptr.md
Normal file
@@ -0,0 +1,23 @@
|
||||
[func.wrap.func.nullptr]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.func.nullptr)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#func.nullptr)
|
||||
|
||||
#### 22.10.17.3 Class template function [[func.wrap.func]](func.wrap.func#nullptr)
|
||||
|
||||
#### 22.10.17.3.7 Null pointer comparison operator functions [func.wrap.func.nullptr]
|
||||
|
||||
[ð](#lib:operator==,function)
|
||||
|
||||
`template<class R, class... ArgTypes>
|
||||
bool operator==(const function<R(ArgTypes...)>& f, nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14066)
|
||||
|
||||
*Returns*: !f[.](#1.sentence-1)
|
||||
34
cppdraft/func/wrap/func/targ.md
Normal file
34
cppdraft/func/wrap/func/targ.md
Normal file
@@ -0,0 +1,34 @@
|
||||
[func.wrap.func.targ]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.func.targ)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#func.targ)
|
||||
|
||||
#### 22.10.17.3 Class template function [[func.wrap.func]](func.wrap.func#targ)
|
||||
|
||||
#### 22.10.17.3.6 Target access [func.wrap.func.targ]
|
||||
|
||||
[ð](#lib:target_type,function)
|
||||
|
||||
`const type_info& target_type() const noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14038)
|
||||
|
||||
*Returns*: If *this has a target of type T, typeid(T); otherwise, typeid(void)[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:target,function)
|
||||
|
||||
`template<class T> T* target() noexcept;
|
||||
template<class T> const T* target() const noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14051)
|
||||
|
||||
*Returns*: If target_type() == typeid(T) a pointer to the stored function target; otherwise a null pointer[.](#2.sentence-1)
|
||||
39
cppdraft/func/wrap/general.md
Normal file
39
cppdraft/func/wrap/general.md
Normal file
@@ -0,0 +1,39 @@
|
||||
[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)
|
||||
428
cppdraft/func/wrap/move.md
Normal file
428
cppdraft/func/wrap/move.md
Normal file
@@ -0,0 +1,428 @@
|
||||
[func.wrap.move]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.move)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#move)
|
||||
|
||||
#### 22.10.17.4 Move-only wrapper [func.wrap.move]
|
||||
|
||||
#### [22.10.17.4.1](#general) General [[func.wrap.move.general]](func.wrap.move.general)
|
||||
|
||||
[1](#general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14089)
|
||||
|
||||
The header provides partial specializations of move_only_function for each combination of the possible replacements
|
||||
of the placeholders cv, *ref*, and *noex* where
|
||||
|
||||
- [(1.1)](#general-1.1)
|
||||
|
||||
cv is either const or empty,
|
||||
|
||||
- [(1.2)](#general-1.2)
|
||||
|
||||
*ref* is either &, &&, or empty, and
|
||||
|
||||
- [(1.3)](#general-1.3)
|
||||
|
||||
*noex* is either true or false[.](#general-1.sentence-1)
|
||||
|
||||
[2](#general-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14102)
|
||||
|
||||
For each of the possible combinations of the placeholders mentioned above,
|
||||
there is a placeholder *inv-quals* defined as follows:
|
||||
|
||||
- [(2.1)](#general-2.1)
|
||||
|
||||
If *ref* is empty, let *inv-quals* be cv&,
|
||||
|
||||
- [(2.2)](#general-2.2)
|
||||
|
||||
otherwise, let *inv-quals* be cv *ref*[.](#general-2.sentence-1)
|
||||
|
||||
#### [22.10.17.4.2](#class) Class template move_only_function [[func.wrap.move.class]](func.wrap.move.class)
|
||||
|
||||
[ð](#lib:move_only_function)
|
||||
|
||||
namespace std {template<class R, class... ArgTypes>class move_only_function<R(ArgTypes...) cv *ref* noexcept(*noex*)> {public:using result_type = R; // [[func.wrap.move.ctor]](#ctor "22.10.17.4.3 Constructors, assignments, and destructor"), constructors, assignments, and destructor move_only_function() noexcept;
|
||||
move_only_function(nullptr_t) noexcept;
|
||||
move_only_function(move_only_function&&) noexcept; template<class F> move_only_function(F&&); template<class T, class... Args>explicit move_only_function(in_place_type_t<T>, Args&&...); template<class T, class U, class... Args>explicit move_only_function(in_place_type_t<T>, initializer_list<U>, Args&&...);
|
||||
|
||||
move_only_function& operator=(move_only_function&&);
|
||||
move_only_function& operator=(nullptr_t) noexcept; template<class F> move_only_function& operator=(F&&); ~move_only_function(); // [[func.wrap.move.inv]](#inv "22.10.17.4.4 Invocation"), invocationexplicit operator bool() const noexcept;
|
||||
R operator()(ArgTypes...) cv *ref* noexcept(*noex*); // [[func.wrap.move.util]](#util "22.10.17.4.5 Utility"), utilityvoid swap(move_only_function&) noexcept; friend void swap(move_only_function&, move_only_function&) noexcept; friend bool operator==(const move_only_function&, nullptr_t) noexcept; private:template<class VT>static constexpr bool *is-callable-from* = *see below*; // *exposition only*};}
|
||||
|
||||
[1](#class-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14154)
|
||||
|
||||
The move_only_function class template provides polymorphic wrappers
|
||||
that generalize the notion of a callable object ([[func.def]](func.def "22.10.3 Definitions"))[.](#class-1.sentence-1)
|
||||
|
||||
These wrappers can store, move, and call arbitrary callable objects,
|
||||
given a call signature[.](#class-1.sentence-2)
|
||||
|
||||
[2](#class-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14160)
|
||||
|
||||
*Recommended practice*: Implementations should avoid the use of dynamically allocated memory
|
||||
for a small contained value[.](#class-2.sentence-1)
|
||||
|
||||
[*Note [1](#class-note-1)*:
|
||||
|
||||
Such small-object optimization can only be applied to a type T for which is_nothrow_move_constructible_v<T> is true[.](#class-2.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
#### [22.10.17.4.3](#ctor) Constructors, assignments, and destructor [[func.wrap.move.ctor]](func.wrap.move.ctor)
|
||||
|
||||
[ð](#:move_only_function::is-callable-from)
|
||||
|
||||
`template<class VT>
|
||||
static constexpr bool is-callable-from = see below;
|
||||
`
|
||||
|
||||
[1](#ctor-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14178)
|
||||
|
||||
If *noex* is true,*is-callable-from*<VT> is equal to:is_nothrow_invocable_r_v<R, VT cv *ref*, ArgTypes...> && is_nothrow_invocable_r_v<R, VT *inv-quals*, ArgTypes...>
|
||||
|
||||
Otherwise, *is-callable-from*<VT> is equal to:is_invocable_r_v<R, VT cv *ref*, ArgTypes...> && is_invocable_r_v<R, VT *inv-quals*, ArgTypes...>
|
||||
|
||||
[ð](#lib:move_only_function,constructor)
|
||||
|
||||
`move_only_function() noexcept;
|
||||
move_only_function(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[2](#ctor-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14199)
|
||||
|
||||
*Postconditions*: *this has no target object[.](#ctor-2.sentence-1)
|
||||
|
||||
[ð](#lib:move_only_function,constructor_)
|
||||
|
||||
`move_only_function(move_only_function&& f) noexcept;
|
||||
`
|
||||
|
||||
[3](#ctor-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14210)
|
||||
|
||||
*Postconditions*: The target object of *this is
|
||||
the target object f had before construction, andf is in a valid state with an unspecified value[.](#ctor-3.sentence-1)
|
||||
|
||||
[ð](#lib:move_only_function,constructor__)
|
||||
|
||||
`template<class F> move_only_function(F&& f);
|
||||
`
|
||||
|
||||
[4](#ctor-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14223)
|
||||
|
||||
Let VT be decay_t<F>[.](#ctor-4.sentence-1)
|
||||
|
||||
[5](#ctor-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14226)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(5.1)](#ctor-5.1)
|
||||
|
||||
remove_cvref_t<F> is not the same type as move_only_function, and
|
||||
|
||||
- [(5.2)](#ctor-5.2)
|
||||
|
||||
remove_cvref_t<F> is not a specialization of in_place_type_t, and
|
||||
|
||||
- [(5.3)](#ctor-5.3)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#ctor-5.sentence-1)
|
||||
|
||||
[6](#ctor-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14237)
|
||||
|
||||
*Mandates*: is_constructible_v<VT, F> is true[.](#ctor-6.sentence-1)
|
||||
|
||||
[7](#ctor-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14241)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements, and
|
||||
if is_move_constructible_v<VT> is true,VT meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#ctor-7.sentence-1)
|
||||
|
||||
[8](#ctor-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14247)
|
||||
|
||||
*Postconditions*: *this has no target object if any of the following hold:
|
||||
|
||||
- [(8.1)](#ctor-8.1)
|
||||
|
||||
f is a null function pointer value, or
|
||||
|
||||
- [(8.2)](#ctor-8.2)
|
||||
|
||||
f is a null member pointer value, or
|
||||
|
||||
- [(8.3)](#ctor-8.3)
|
||||
|
||||
remove_cvref_t<F> is a specialization of
|
||||
the move_only_function class template,
|
||||
and f has no target object[.](#ctor-8.sentence-1)
|
||||
|
||||
Otherwise, *this has a target object of type VT direct-non-list-initialized with std::forward<F>(f)[.](#ctor-8.sentence-2)
|
||||
|
||||
[9](#ctor-9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14263)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#ctor-9.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a function pointer or a specialization of reference_wrapper[.](#ctor-9.sentence-2)
|
||||
|
||||
[ð](#lib:move_only_function,constructor___)
|
||||
|
||||
`template<class T, class... Args>
|
||||
explicit move_only_function(in_place_type_t<T>, Args&&... args);
|
||||
`
|
||||
|
||||
[10](#ctor-10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14277)
|
||||
|
||||
Let VT be decay_t<T>[.](#ctor-10.sentence-1)
|
||||
|
||||
[11](#ctor-11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14280)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(11.1)](#ctor-11.1)
|
||||
|
||||
is_constructible_v<VT, Args...> is true, and
|
||||
|
||||
- [(11.2)](#ctor-11.2)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#ctor-11.sentence-1)
|
||||
|
||||
[12](#ctor-12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14289)
|
||||
|
||||
*Mandates*: VT is the same type as T[.](#ctor-12.sentence-1)
|
||||
|
||||
[13](#ctor-13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14293)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements, and
|
||||
if is_move_constructible_v<VT> is true,VT meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#ctor-13.sentence-1)
|
||||
|
||||
[14](#ctor-14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14299)
|
||||
|
||||
*Postconditions*: *this has a target object of type VT direct-non-list-initialized with std::forward<Args>(args)...[.](#ctor-14.sentence-1)
|
||||
|
||||
[15](#ctor-15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14304)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#ctor-15.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a function pointer or a specialization of reference_wrapper[.](#ctor-15.sentence-2)
|
||||
|
||||
[ð](#lib:move_only_function,constructor____)
|
||||
|
||||
`template<class T, class U, class... Args>
|
||||
explicit move_only_function(in_place_type_t<T>, initializer_list<U> ilist, Args&&... args);
|
||||
`
|
||||
|
||||
[16](#ctor-16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14318)
|
||||
|
||||
Let VT be decay_t<T>[.](#ctor-16.sentence-1)
|
||||
|
||||
[17](#ctor-17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14321)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(17.1)](#ctor-17.1)
|
||||
|
||||
is_constructible_v<VT, initializer_list<U>&, Args...> istrue, and
|
||||
|
||||
- [(17.2)](#ctor-17.2)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#ctor-17.sentence-1)
|
||||
|
||||
[18](#ctor-18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14331)
|
||||
|
||||
*Mandates*: VT is the same type as T[.](#ctor-18.sentence-1)
|
||||
|
||||
[19](#ctor-19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14335)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements, and
|
||||
if is_move_constructible_v<VT> is true,VT meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#ctor-19.sentence-1)
|
||||
|
||||
[20](#ctor-20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14341)
|
||||
|
||||
*Postconditions*: *this has a target object of type VT direct-non-list-initialized withilist, std::forward<Args>(args)...[.](#ctor-20.sentence-1)
|
||||
|
||||
[21](#ctor-21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14347)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#ctor-21.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a function pointer or a specialization of reference_wrapper[.](#ctor-21.sentence-2)
|
||||
|
||||
[ð](#lib:operator=,move_only_function)
|
||||
|
||||
`move_only_function& operator=(move_only_function&& f);
|
||||
`
|
||||
|
||||
[22](#ctor-22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14360)
|
||||
|
||||
*Effects*: Equivalent to: move_only_function(std::move(f)).swap(*this);
|
||||
|
||||
[23](#ctor-23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14364)
|
||||
|
||||
*Returns*: *this[.](#ctor-23.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,move_only_function_)
|
||||
|
||||
`move_only_function& operator=(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[24](#ctor-24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14375)
|
||||
|
||||
*Effects*: Destroys the target object of *this, if any[.](#ctor-24.sentence-1)
|
||||
|
||||
[25](#ctor-25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14379)
|
||||
|
||||
*Returns*: *this[.](#ctor-25.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,move_only_function__)
|
||||
|
||||
`template<class F> move_only_function& operator=(F&& f);
|
||||
`
|
||||
|
||||
[26](#ctor-26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14390)
|
||||
|
||||
*Effects*: Equivalent to: move_only_function(std::forward<F>(f)).swap(*this);
|
||||
|
||||
[27](#ctor-27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14394)
|
||||
|
||||
*Returns*: *this[.](#ctor-27.sentence-1)
|
||||
|
||||
[ð](#lib:move_only_function,destructor)
|
||||
|
||||
`~move_only_function();
|
||||
`
|
||||
|
||||
[28](#ctor-28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14405)
|
||||
|
||||
*Effects*: Destroys the target object of *this, if any[.](#ctor-28.sentence-1)
|
||||
|
||||
#### [22.10.17.4.4](#inv) Invocation [[func.wrap.move.inv]](func.wrap.move.inv)
|
||||
|
||||
[ð](#lib:operator_bool,move_only_function)
|
||||
|
||||
`explicit operator bool() const noexcept;
|
||||
`
|
||||
|
||||
[1](#inv-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14418)
|
||||
|
||||
*Returns*: true if *this has a target object, otherwise false[.](#inv-1.sentence-1)
|
||||
|
||||
[ð](#lib:operator(),move_only_function)
|
||||
|
||||
`R operator()(ArgTypes... args) cv ref noexcept(noex);
|
||||
`
|
||||
|
||||
[2](#inv-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14429)
|
||||
|
||||
*Preconditions*: *this has a target object[.](#inv-2.sentence-1)
|
||||
|
||||
[3](#inv-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14433)
|
||||
|
||||
*Effects*: Equivalent to:return *INVOKE*<R>(static_cast<F *inv-quals*>(f), std::forward<ArgTypes>(args)...); where f is an lvalue designating the target object of *this andF is the type of f[.](#inv-3.sentence-1)
|
||||
|
||||
#### [22.10.17.4.5](#util) Utility [[func.wrap.move.util]](func.wrap.move.util)
|
||||
|
||||
[ð](#lib:swap,move_only_function)
|
||||
|
||||
`void swap(move_only_function& other) noexcept;
|
||||
`
|
||||
|
||||
[1](#util-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14451)
|
||||
|
||||
*Effects*: Exchanges the target objects of *this and other[.](#util-1.sentence-1)
|
||||
|
||||
[ð](#lib:swap,move_only_function_)
|
||||
|
||||
`friend void swap(move_only_function& f1, move_only_function& f2) noexcept;
|
||||
`
|
||||
|
||||
[2](#util-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14462)
|
||||
|
||||
*Effects*: Equivalent to f1.swap(f2)[.](#util-2.sentence-1)
|
||||
|
||||
[ð](#lib:operator==,move_only_function)
|
||||
|
||||
`friend bool operator==(const move_only_function& f, nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[3](#util-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14473)
|
||||
|
||||
*Returns*: true if f has no target object, otherwise false[.](#util-3.sentence-1)
|
||||
44
cppdraft/func/wrap/move/class.md
Normal file
44
cppdraft/func/wrap/move/class.md
Normal file
@@ -0,0 +1,44 @@
|
||||
[func.wrap.move.class]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.move.class)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#move.class)
|
||||
|
||||
#### 22.10.17.4 Move-only wrapper [[func.wrap.move]](func.wrap.move#class)
|
||||
|
||||
#### 22.10.17.4.2 Class template move_only_function [func.wrap.move.class]
|
||||
|
||||
[ð](#lib:move_only_function)
|
||||
|
||||
namespace std {template<class R, class... ArgTypes>class move_only_function<R(ArgTypes...) cv *ref* noexcept(*noex*)> {public:using result_type = R; // [[func.wrap.move.ctor]](func.wrap.move.ctor "22.10.17.4.3 Constructors, assignments, and destructor"), constructors, assignments, and destructor move_only_function() noexcept;
|
||||
move_only_function(nullptr_t) noexcept;
|
||||
move_only_function(move_only_function&&) noexcept; template<class F> move_only_function(F&&); template<class T, class... Args>explicit move_only_function(in_place_type_t<T>, Args&&...); template<class T, class U, class... Args>explicit move_only_function(in_place_type_t<T>, initializer_list<U>, Args&&...);
|
||||
|
||||
move_only_function& operator=(move_only_function&&);
|
||||
move_only_function& operator=(nullptr_t) noexcept; template<class F> move_only_function& operator=(F&&); ~move_only_function(); // [[func.wrap.move.inv]](func.wrap.move.inv "22.10.17.4.4 Invocation"), invocationexplicit operator bool() const noexcept;
|
||||
R operator()(ArgTypes...) cv *ref* noexcept(*noex*); // [[func.wrap.move.util]](func.wrap.move.util "22.10.17.4.5 Utility"), utilityvoid swap(move_only_function&) noexcept; friend void swap(move_only_function&, move_only_function&) noexcept; friend bool operator==(const move_only_function&, nullptr_t) noexcept; private:template<class VT>static constexpr bool *is-callable-from* = *see below*; // *exposition only*};}
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14154)
|
||||
|
||||
The move_only_function class template provides polymorphic wrappers
|
||||
that generalize the notion of a callable object ([[func.def]](func.def "22.10.3 Definitions"))[.](#1.sentence-1)
|
||||
|
||||
These wrappers can store, move, and call arbitrary callable objects,
|
||||
given a call signature[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14160)
|
||||
|
||||
*Recommended practice*: Implementations should avoid the use of dynamically allocated memory
|
||||
for a small contained value[.](#2.sentence-1)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
Such small-object optimization can only be applied to a type T for which is_nothrow_move_constructible_v<T> is true[.](#2.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
292
cppdraft/func/wrap/move/ctor.md
Normal file
292
cppdraft/func/wrap/move/ctor.md
Normal file
@@ -0,0 +1,292 @@
|
||||
[func.wrap.move.ctor]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.move.ctor)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#move.ctor)
|
||||
|
||||
#### 22.10.17.4 Move-only wrapper [[func.wrap.move]](func.wrap.move#ctor)
|
||||
|
||||
#### 22.10.17.4.3 Constructors, assignments, and destructor [func.wrap.move.ctor]
|
||||
|
||||
[ð](#:move_only_function::is-callable-from)
|
||||
|
||||
`template<class VT>
|
||||
static constexpr bool is-callable-from = see below;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14178)
|
||||
|
||||
If *noex* is true,*is-callable-from*<VT> is equal to:is_nothrow_invocable_r_v<R, VT cv *ref*, ArgTypes...> && is_nothrow_invocable_r_v<R, VT *inv-quals*, ArgTypes...>
|
||||
|
||||
Otherwise, *is-callable-from*<VT> is equal to:is_invocable_r_v<R, VT cv *ref*, ArgTypes...> && is_invocable_r_v<R, VT *inv-quals*, ArgTypes...>
|
||||
|
||||
[ð](#lib:move_only_function,constructor)
|
||||
|
||||
`move_only_function() noexcept;
|
||||
move_only_function(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14199)
|
||||
|
||||
*Postconditions*: *this has no target object[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:move_only_function,constructor_)
|
||||
|
||||
`move_only_function(move_only_function&& f) noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14210)
|
||||
|
||||
*Postconditions*: The target object of *this is
|
||||
the target object f had before construction, andf is in a valid state with an unspecified value[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:move_only_function,constructor__)
|
||||
|
||||
`template<class F> move_only_function(F&& f);
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14223)
|
||||
|
||||
Let VT be decay_t<F>[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14226)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(5.1)](#5.1)
|
||||
|
||||
remove_cvref_t<F> is not the same type as move_only_function, and
|
||||
|
||||
- [(5.2)](#5.2)
|
||||
|
||||
remove_cvref_t<F> is not a specialization of in_place_type_t, and
|
||||
|
||||
- [(5.3)](#5.3)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14237)
|
||||
|
||||
*Mandates*: is_constructible_v<VT, F> is true[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14241)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements, and
|
||||
if is_move_constructible_v<VT> is true,VT meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14247)
|
||||
|
||||
*Postconditions*: *this has no target object if any of the following hold:
|
||||
|
||||
- [(8.1)](#8.1)
|
||||
|
||||
f is a null function pointer value, or
|
||||
|
||||
- [(8.2)](#8.2)
|
||||
|
||||
f is a null member pointer value, or
|
||||
|
||||
- [(8.3)](#8.3)
|
||||
|
||||
remove_cvref_t<F> is a specialization of
|
||||
the move_only_function class template,
|
||||
and f has no target object[.](#8.sentence-1)
|
||||
|
||||
Otherwise, *this has a target object of type VT direct-non-list-initialized with std::forward<F>(f)[.](#8.sentence-2)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14263)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#9.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a function pointer or a specialization of reference_wrapper[.](#9.sentence-2)
|
||||
|
||||
[ð](#lib:move_only_function,constructor___)
|
||||
|
||||
`template<class T, class... Args>
|
||||
explicit move_only_function(in_place_type_t<T>, Args&&... args);
|
||||
`
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14277)
|
||||
|
||||
Let VT be decay_t<T>[.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14280)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(11.1)](#11.1)
|
||||
|
||||
is_constructible_v<VT, Args...> is true, and
|
||||
|
||||
- [(11.2)](#11.2)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14289)
|
||||
|
||||
*Mandates*: VT is the same type as T[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14293)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements, and
|
||||
if is_move_constructible_v<VT> is true,VT meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14299)
|
||||
|
||||
*Postconditions*: *this has a target object of type VT direct-non-list-initialized with std::forward<Args>(args)...[.](#14.sentence-1)
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14304)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#15.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a function pointer or a specialization of reference_wrapper[.](#15.sentence-2)
|
||||
|
||||
[ð](#lib:move_only_function,constructor____)
|
||||
|
||||
`template<class T, class U, class... Args>
|
||||
explicit move_only_function(in_place_type_t<T>, initializer_list<U> ilist, Args&&... args);
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14318)
|
||||
|
||||
Let VT be decay_t<T>[.](#16.sentence-1)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14321)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(17.1)](#17.1)
|
||||
|
||||
is_constructible_v<VT, initializer_list<U>&, Args...> istrue, and
|
||||
|
||||
- [(17.2)](#17.2)
|
||||
|
||||
*is-callable-from*<VT> is true[.](#17.sentence-1)
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14331)
|
||||
|
||||
*Mandates*: VT is the same type as T[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14335)
|
||||
|
||||
*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements, and
|
||||
if is_move_constructible_v<VT> is true,VT meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#19.sentence-1)
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14341)
|
||||
|
||||
*Postconditions*: *this has a target object of type VT direct-non-list-initialized withilist, std::forward<Args>(args)...[.](#20.sentence-1)
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14347)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of the target object[.](#21.sentence-1)
|
||||
|
||||
May throw bad_alloc unless VT is
|
||||
a function pointer or a specialization of reference_wrapper[.](#21.sentence-2)
|
||||
|
||||
[ð](#lib:operator=,move_only_function)
|
||||
|
||||
`move_only_function& operator=(move_only_function&& f);
|
||||
`
|
||||
|
||||
[22](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14360)
|
||||
|
||||
*Effects*: Equivalent to: move_only_function(std::move(f)).swap(*this);
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14364)
|
||||
|
||||
*Returns*: *this[.](#23.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,move_only_function_)
|
||||
|
||||
`move_only_function& operator=(nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14375)
|
||||
|
||||
*Effects*: Destroys the target object of *this, if any[.](#24.sentence-1)
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14379)
|
||||
|
||||
*Returns*: *this[.](#25.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,move_only_function__)
|
||||
|
||||
`template<class F> move_only_function& operator=(F&& f);
|
||||
`
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14390)
|
||||
|
||||
*Effects*: Equivalent to: move_only_function(std::forward<F>(f)).swap(*this);
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14394)
|
||||
|
||||
*Returns*: *this[.](#27.sentence-1)
|
||||
|
||||
[ð](#lib:move_only_function,destructor)
|
||||
|
||||
`~move_only_function();
|
||||
`
|
||||
|
||||
[28](#28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14405)
|
||||
|
||||
*Effects*: Destroys the target object of *this, if any[.](#28.sentence-1)
|
||||
45
cppdraft/func/wrap/move/general.md
Normal file
45
cppdraft/func/wrap/move/general.md
Normal file
@@ -0,0 +1,45 @@
|
||||
[func.wrap.move.general]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.move.general)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#move.general)
|
||||
|
||||
#### 22.10.17.4 Move-only wrapper [[func.wrap.move]](func.wrap.move#general)
|
||||
|
||||
#### 22.10.17.4.1 General [func.wrap.move.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14089)
|
||||
|
||||
The header provides partial specializations of move_only_function for each combination of the possible replacements
|
||||
of the placeholders cv, *ref*, and *noex* where
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
cv is either const or empty,
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
*ref* is either &, &&, or empty, and
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
*noex* is either true or false[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14102)
|
||||
|
||||
For each of the possible combinations of the placeholders mentioned above,
|
||||
there is a placeholder *inv-quals* defined as follows:
|
||||
|
||||
- [(2.1)](#2.1)
|
||||
|
||||
If *ref* is empty, let *inv-quals* be cv&,
|
||||
|
||||
- [(2.2)](#2.2)
|
||||
|
||||
otherwise, let *inv-quals* be cv *ref*[.](#2.sentence-1)
|
||||
39
cppdraft/func/wrap/move/inv.md
Normal file
39
cppdraft/func/wrap/move/inv.md
Normal file
@@ -0,0 +1,39 @@
|
||||
[func.wrap.move.inv]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.move.inv)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#move.inv)
|
||||
|
||||
#### 22.10.17.4 Move-only wrapper [[func.wrap.move]](func.wrap.move#inv)
|
||||
|
||||
#### 22.10.17.4.4 Invocation [func.wrap.move.inv]
|
||||
|
||||
[ð](#lib:operator_bool,move_only_function)
|
||||
|
||||
`explicit operator bool() const noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14418)
|
||||
|
||||
*Returns*: true if *this has a target object, otherwise false[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:operator(),move_only_function)
|
||||
|
||||
`R operator()(ArgTypes... args) cv ref noexcept(noex);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14429)
|
||||
|
||||
*Preconditions*: *this has a target object[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14433)
|
||||
|
||||
*Effects*: Equivalent to:return *INVOKE*<R>(static_cast<F *inv-quals*>(f), std::forward<ArgTypes>(args)...); where f is an lvalue designating the target object of *this andF is the type of f[.](#3.sentence-1)
|
||||
44
cppdraft/func/wrap/move/util.md
Normal file
44
cppdraft/func/wrap/move/util.md
Normal file
@@ -0,0 +1,44 @@
|
||||
[func.wrap.move.util]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.move.util)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#move.util)
|
||||
|
||||
#### 22.10.17.4 Move-only wrapper [[func.wrap.move]](func.wrap.move#util)
|
||||
|
||||
#### 22.10.17.4.5 Utility [func.wrap.move.util]
|
||||
|
||||
[ð](#lib:swap,move_only_function)
|
||||
|
||||
`void swap(move_only_function& other) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14451)
|
||||
|
||||
*Effects*: Exchanges the target objects of *this and other[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:swap,move_only_function_)
|
||||
|
||||
`friend void swap(move_only_function& f1, move_only_function& f2) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14462)
|
||||
|
||||
*Effects*: Equivalent to f1.swap(f2)[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:operator==,move_only_function)
|
||||
|
||||
`friend bool operator==(const move_only_function& f, nullptr_t) noexcept;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14473)
|
||||
|
||||
*Returns*: true if f has no target object, otherwise false[.](#3.sentence-1)
|
||||
361
cppdraft/func/wrap/ref.md
Normal file
361
cppdraft/func/wrap/ref.md
Normal file
@@ -0,0 +1,361 @@
|
||||
[func.wrap.ref]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.ref)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#ref)
|
||||
|
||||
#### 22.10.17.6 Non-owning wrapper [func.wrap.ref]
|
||||
|
||||
#### [22.10.17.6.1](#general) General [[func.wrap.ref.general]](func.wrap.ref.general)
|
||||
|
||||
[1](#general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14922)
|
||||
|
||||
The header provides partial specializations of function_ref for each combination of the possible replacements of
|
||||
the placeholders cv and *noex* where:
|
||||
|
||||
- [(1.1)](#general-1.1)
|
||||
|
||||
cv is either const or empty, and
|
||||
|
||||
- [(1.2)](#general-1.2)
|
||||
|
||||
*noex* is either true or false[.](#general-1.sentence-1)
|
||||
|
||||
#### [22.10.17.6.2](#class) Class template function_ref [[func.wrap.ref.class]](func.wrap.ref.class)
|
||||
|
||||
[ð](#lib:function_ref)
|
||||
|
||||
namespace std {template<class R, class... ArgTypes>class function_ref<R(ArgTypes...) cv noexcept(*noex*)> {public:// [[func.wrap.ref.ctor]](#ctor "22.10.17.6.3 Constructors and assignment operators"), constructors and assignment operatorstemplate<class F> function_ref(F*) noexcept; template<class F> constexpr function_ref(F&&) noexcept; template<auto f> constexpr function_ref(nontype_t<f>) noexcept; template<auto f, class U> constexpr function_ref(nontype_t<f>, U&&) noexcept; template<auto f, class T> constexpr function_ref(nontype_t<f>, cv T*) noexcept; constexpr function_ref(const function_ref&) noexcept = default; constexpr function_ref& operator=(const function_ref&) noexcept = default; template<class T> function_ref& operator=(T) = delete; // [[func.wrap.ref.inv]](#inv "22.10.17.6.4 Invocation"), invocation R operator()(ArgTypes...) const noexcept(*noex*); private:template<class... T>static constexpr bool *is-invocable-using* = *see below*; // *exposition only* R (**thunk-ptr*)(*BoundEntityType*, Args&&...) noexcept(*noex*); // *exposition only**BoundEntityType* *bound-entity*; // *exposition only*}; // [[func.wrap.ref.deduct]](#deduct "22.10.17.6.5 Deduction guides"), deduction guidestemplate<class F> function_ref(F*) -> function_ref<F>; template<auto f> function_ref(nontype_t<f>) -> function_ref<*see below*>; template<auto f, class T> function_ref(nontype_t<f>, T&&) -> function_ref<*see below*>;}
|
||||
|
||||
[1](#class-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14971)
|
||||
|
||||
An object of classfunction_ref<R(Args...) cv noexcept(*noex*)> stores a pointer to function *thunk-ptr* and
|
||||
an object *bound-entity*[.](#class-1.sentence-1)
|
||||
|
||||
*bound-entity* has
|
||||
an unspecified trivially copyable type *BoundEntityType*, that
|
||||
models [copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]") and
|
||||
is capable of storing a pointer to object value or a pointer to function value[.](#class-1.sentence-2)
|
||||
|
||||
The type of *thunk-ptr* isR(*)(*BoundEntityType*, Args&&...) noexcept(*noex*)[.](#class-1.sentence-3)
|
||||
|
||||
[2](#class-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14983)
|
||||
|
||||
Each specialization of function_ref is
|
||||
a trivially copyable type ([[basic.types.general]](basic.types.general#term.trivially.copyable.type "6.9.1 General"))
|
||||
that models [copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]")[.](#class-2.sentence-1)
|
||||
|
||||
[3](#class-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14988)
|
||||
|
||||
Within [func.wrap.ref],*call-args* is an argument pack with elements such thatdecltype((*call-args*))... denoteArgs&&... respectively[.](#class-3.sentence-1)
|
||||
|
||||
#### [22.10.17.6.3](#ctor) Constructors and assignment operators [[func.wrap.ref.ctor]](func.wrap.ref.ctor)
|
||||
|
||||
[ð](#:function_ref::is-invocable-using)
|
||||
|
||||
`template<class... T>
|
||||
static constexpr bool is-invocable-using = see below;
|
||||
`
|
||||
|
||||
[1](#ctor-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15003)
|
||||
|
||||
If *noex* is true,*is-invocable-using*<T...> is equal to:is_nothrow_invocable_r_v<R, T..., ArgTypes...>
|
||||
|
||||
Otherwise, *is-invocable-using*<T...> is equal to:is_invocable_r_v<R, T..., ArgTypes...>
|
||||
|
||||
[ð](#lib:function_ref,constructor)
|
||||
|
||||
`template<class F> function_ref(F* f) noexcept;
|
||||
`
|
||||
|
||||
[2](#ctor-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15021)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(2.1)](#ctor-2.1)
|
||||
|
||||
is_function_v<F> is true, and
|
||||
|
||||
- [(2.2)](#ctor-2.2)
|
||||
|
||||
*is-invocable-using*<F> is true[.](#ctor-2.sentence-1)
|
||||
|
||||
[3](#ctor-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15028)
|
||||
|
||||
*Preconditions*: f is not a null pointer[.](#ctor-3.sentence-1)
|
||||
|
||||
[4](#ctor-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15032)
|
||||
|
||||
*Effects*: Initializes*bound-entity* with f, and*thunk-ptr* with the address of a function *thunk* such that*thunk*(*bound-entity*, *call-args*...) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) toinvoke_r<R>(f, *call-args*...)[.](#ctor-4.sentence-1)
|
||||
|
||||
[ð](#lib:function_ref,constructor_)
|
||||
|
||||
`template<class F> constexpr function_ref(F&& f) noexcept;
|
||||
`
|
||||
|
||||
[5](#ctor-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15049)
|
||||
|
||||
Let T be remove_reference_t<F>[.](#ctor-5.sentence-1)
|
||||
|
||||
[6](#ctor-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15052)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(6.1)](#ctor-6.1)
|
||||
|
||||
remove_cvref_t<F> is not the same type as function_ref,
|
||||
|
||||
- [(6.2)](#ctor-6.2)
|
||||
|
||||
is_member_pointer_v<T> is false, and
|
||||
|
||||
- [(6.3)](#ctor-6.3)
|
||||
|
||||
*is-invocable-using*<cv T&> is true[.](#ctor-6.sentence-1)
|
||||
|
||||
[7](#ctor-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15060)
|
||||
|
||||
*Effects*: Initializes*bound-entity* with addressof(f), and*thunk-ptr* with the address of a function *thunk* such that*thunk*(*bound-entity*, *call-args*...) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) toinvoke_r<R>(static_cast<cv T&>(f), *call-args*...)[.](#ctor-7.sentence-1)
|
||||
|
||||
[ð](#lib:function_ref,constructor__)
|
||||
|
||||
`template<auto f> constexpr function_ref(nontype_t<f>) noexcept;
|
||||
`
|
||||
|
||||
[8](#ctor-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15077)
|
||||
|
||||
Let F be decltype(f)[.](#ctor-8.sentence-1)
|
||||
|
||||
[9](#ctor-9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15080)
|
||||
|
||||
*Constraints*: *is-invocable-using*<F> is true[.](#ctor-9.sentence-1)
|
||||
|
||||
[10](#ctor-10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15084)
|
||||
|
||||
*Mandates*: If is_pointer_v<F> || is_member_pointer_v<F> is true,
|
||||
then f != nullptr is true[.](#ctor-10.sentence-1)
|
||||
|
||||
[11](#ctor-11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15089)
|
||||
|
||||
*Effects*: Initializes*bound-entity* with a pointer to an unspecified object or
|
||||
null pointer value, and*thunk-ptr* with the address of a function *thunk* such that*thunk*(*bound-entity*, *call-args*...) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) toinvoke_r<R>(f, *call-args*...)[.](#ctor-11.sentence-1)
|
||||
|
||||
[ð](#lib:function_ref,constructor___)
|
||||
|
||||
`template<auto f, class U>
|
||||
constexpr function_ref(nontype_t<f>, U&& obj) noexcept;
|
||||
`
|
||||
|
||||
[12](#ctor-12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15108)
|
||||
|
||||
Let T be remove_reference_t<U> andF be decltype(f)[.](#ctor-12.sentence-1)
|
||||
|
||||
[13](#ctor-13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15112)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(13.1)](#ctor-13.1)
|
||||
|
||||
is_rvalue_reference_v<U&&> is false, and
|
||||
|
||||
- [(13.2)](#ctor-13.2)
|
||||
|
||||
*is-invocable-using*<F, cv T&> is true[.](#ctor-13.sentence-1)
|
||||
|
||||
[14](#ctor-14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15119)
|
||||
|
||||
*Mandates*: If is_pointer_v<F> || is_member_pointer_v<F> is true,
|
||||
then f != nullptr is true[.](#ctor-14.sentence-1)
|
||||
|
||||
[15](#ctor-15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15124)
|
||||
|
||||
*Effects*: Initializes*bound-entity* with addressof(obj), and*thunk-ptr* with the address of a function *thunk* such that*thunk*(*bound-entity*, *call-args*...) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) toinvoke_r<R>(f, static_cast<cv T&>(obj), *call-args*...)[.](#ctor-15.sentence-1)
|
||||
|
||||
[ð](#lib:function_ref,constructor____)
|
||||
|
||||
`template<auto f, class T>
|
||||
constexpr function_ref(nontype_t<f>, cv T* obj) noexcept;
|
||||
`
|
||||
|
||||
[16](#ctor-16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15142)
|
||||
|
||||
Let F be decltype(f)[.](#ctor-16.sentence-1)
|
||||
|
||||
[17](#ctor-17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15145)
|
||||
|
||||
*Constraints*: *is-invocable-using*<F, cv T*> is true[.](#ctor-17.sentence-1)
|
||||
|
||||
[18](#ctor-18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15149)
|
||||
|
||||
*Mandates*: If is_pointer_v<F> || is_member_pointer_v<F> is true,
|
||||
then f != nullptr is true[.](#ctor-18.sentence-1)
|
||||
|
||||
[19](#ctor-19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15154)
|
||||
|
||||
*Preconditions*: If is_member_pointer_v<F> is true,obj is not a null pointer[.](#ctor-19.sentence-1)
|
||||
|
||||
[20](#ctor-20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15159)
|
||||
|
||||
*Effects*: Initializes*bound-entity* with obj, and*thunk-ptr* with the address of a function *thunk* such that*thunk*(*bound-entity*, *call-args*...) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) toinvoke_r<R>(f, obj, *call-args*...)[.](#ctor-20.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,function_ref)
|
||||
|
||||
`template<class T> function_ref& operator=(T) = delete;
|
||||
`
|
||||
|
||||
[21](#ctor-21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15176)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(21.1)](#ctor-21.1)
|
||||
|
||||
T is not the same type as function_ref,
|
||||
|
||||
- [(21.2)](#ctor-21.2)
|
||||
|
||||
is_pointer_v<T> is false, and
|
||||
|
||||
- [(21.3)](#ctor-21.3)
|
||||
|
||||
T is not a specialization of nontype_t[.](#ctor-21.sentence-1)
|
||||
|
||||
#### [22.10.17.6.4](#inv) Invocation [[func.wrap.ref.inv]](func.wrap.ref.inv)
|
||||
|
||||
[ð](#lib:operator(),function_ref)
|
||||
|
||||
`R operator()(ArgTypes... args) const noexcept(noex);
|
||||
`
|
||||
|
||||
[1](#inv-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15193)
|
||||
|
||||
*Effects*: Equivalent to:return *thunk-ptr*(*bound-entity*, std::forward<ArgTypes>(args)...);
|
||||
|
||||
#### [22.10.17.6.5](#deduct) Deduction guides [[func.wrap.ref.deduct]](func.wrap.ref.deduct)
|
||||
|
||||
[ð](#deduct-itemdecl:1)
|
||||
|
||||
`template<class F>
|
||||
function_ref(F*) -> function_ref<F>;
|
||||
`
|
||||
|
||||
[1](#deduct-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15207)
|
||||
|
||||
*Constraints*: is_function_v<F> is true[.](#deduct-1.sentence-1)
|
||||
|
||||
[ð](#deduct-itemdecl:2)
|
||||
|
||||
`template<auto f>
|
||||
function_ref(nontype_t<f>) -> function_ref<see below>;
|
||||
`
|
||||
|
||||
[2](#deduct-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15218)
|
||||
|
||||
Let F be remove_pointer_t<decltype(f)>[.](#deduct-2.sentence-1)
|
||||
|
||||
[3](#deduct-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15221)
|
||||
|
||||
*Constraints*: is_function_v<F> is true[.](#deduct-3.sentence-1)
|
||||
|
||||
[4](#deduct-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15225)
|
||||
|
||||
*Remarks*: The deduced type is function_ref<F>[.](#deduct-4.sentence-1)
|
||||
|
||||
[ð](#deduct-itemdecl:3)
|
||||
|
||||
`template<auto f, class T>
|
||||
function_ref(nontype_t<f>, T&&) -> function_ref<see below>;
|
||||
`
|
||||
|
||||
[5](#deduct-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15236)
|
||||
|
||||
Let F be decltype(f)[.](#deduct-5.sentence-1)
|
||||
|
||||
[6](#deduct-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15239)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(6.1)](#deduct-6.1)
|
||||
|
||||
F is of the formR(G::*)(A...) cv &opt noexcept(E) for a type G, or
|
||||
|
||||
- [(6.2)](#deduct-6.2)
|
||||
|
||||
F is of the formM G::* for a type G and an object type M,
|
||||
in which case
|
||||
let R be invoke_result_t<F, T&>,A... be an empty pack, andE be false, or
|
||||
|
||||
- [(6.3)](#deduct-6.3)
|
||||
|
||||
F is of the formR(*)(G, A...) noexcept(E) for a type G[.](#deduct-6.sentence-1)
|
||||
|
||||
[7](#deduct-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15259)
|
||||
|
||||
*Remarks*: The deduced type is function_ref<R(A...) noexcept(E)>[.](#deduct-7.sentence-1)
|
||||
43
cppdraft/func/wrap/ref/class.md
Normal file
43
cppdraft/func/wrap/ref/class.md
Normal file
@@ -0,0 +1,43 @@
|
||||
[func.wrap.ref.class]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.ref.class)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#ref.class)
|
||||
|
||||
#### 22.10.17.6 Non-owning wrapper [[func.wrap.ref]](func.wrap.ref#class)
|
||||
|
||||
#### 22.10.17.6.2 Class template function_ref [func.wrap.ref.class]
|
||||
|
||||
[ð](#lib:function_ref)
|
||||
|
||||
namespace std {template<class R, class... ArgTypes>class function_ref<R(ArgTypes...) cv noexcept(*noex*)> {public:// [[func.wrap.ref.ctor]](func.wrap.ref.ctor "22.10.17.6.3 Constructors and assignment operators"), constructors and assignment operatorstemplate<class F> function_ref(F*) noexcept; template<class F> constexpr function_ref(F&&) noexcept; template<auto f> constexpr function_ref(nontype_t<f>) noexcept; template<auto f, class U> constexpr function_ref(nontype_t<f>, U&&) noexcept; template<auto f, class T> constexpr function_ref(nontype_t<f>, cv T*) noexcept; constexpr function_ref(const function_ref&) noexcept = default; constexpr function_ref& operator=(const function_ref&) noexcept = default; template<class T> function_ref& operator=(T) = delete; // [[func.wrap.ref.inv]](func.wrap.ref.inv "22.10.17.6.4 Invocation"), invocation R operator()(ArgTypes...) const noexcept(*noex*); private:template<class... T>static constexpr bool *is-invocable-using* = *see below*; // *exposition only* R (**thunk-ptr*)(*BoundEntityType*, Args&&...) noexcept(*noex*); // *exposition only**BoundEntityType* *bound-entity*; // *exposition only*}; // [[func.wrap.ref.deduct]](func.wrap.ref.deduct "22.10.17.6.5 Deduction guides"), deduction guidestemplate<class F> function_ref(F*) -> function_ref<F>; template<auto f> function_ref(nontype_t<f>) -> function_ref<*see below*>; template<auto f, class T> function_ref(nontype_t<f>, T&&) -> function_ref<*see below*>;}
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14971)
|
||||
|
||||
An object of classfunction_ref<R(Args...) cv noexcept(*noex*)> stores a pointer to function *thunk-ptr* and
|
||||
an object *bound-entity*[.](#1.sentence-1)
|
||||
|
||||
*bound-entity* has
|
||||
an unspecified trivially copyable type *BoundEntityType*, that
|
||||
models [copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]") and
|
||||
is capable of storing a pointer to object value or a pointer to function value[.](#1.sentence-2)
|
||||
|
||||
The type of *thunk-ptr* isR(*)(*BoundEntityType*, Args&&...) noexcept(*noex*)[.](#1.sentence-3)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14983)
|
||||
|
||||
Each specialization of function_ref is
|
||||
a trivially copyable type ([[basic.types.general]](basic.types.general#term.trivially.copyable.type "6.9.1 General"))
|
||||
that models [copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]")[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14988)
|
||||
|
||||
Within [[func.wrap.ref]](func.wrap.ref "22.10.17.6 Non-owning wrapper"),*call-args* is an argument pack with elements such thatdecltype((*call-args*))... denoteArgs&&... respectively[.](#3.sentence-1)
|
||||
221
cppdraft/func/wrap/ref/ctor.md
Normal file
221
cppdraft/func/wrap/ref/ctor.md
Normal file
@@ -0,0 +1,221 @@
|
||||
[func.wrap.ref.ctor]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.ref.ctor)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#ref.ctor)
|
||||
|
||||
#### 22.10.17.6 Non-owning wrapper [[func.wrap.ref]](func.wrap.ref#ctor)
|
||||
|
||||
#### 22.10.17.6.3 Constructors and assignment operators [func.wrap.ref.ctor]
|
||||
|
||||
[ð](#:function_ref::is-invocable-using)
|
||||
|
||||
`template<class... T>
|
||||
static constexpr bool is-invocable-using = see below;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15003)
|
||||
|
||||
If *noex* is true,*is-invocable-using*<T...> is equal to:is_nothrow_invocable_r_v<R, T..., ArgTypes...>
|
||||
|
||||
Otherwise, *is-invocable-using*<T...> is equal to:is_invocable_r_v<R, T..., ArgTypes...>
|
||||
|
||||
[ð](#lib:function_ref,constructor)
|
||||
|
||||
`template<class F> function_ref(F* f) noexcept;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15021)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(2.1)](#2.1)
|
||||
|
||||
is_function_v<F> is true, and
|
||||
|
||||
- [(2.2)](#2.2)
|
||||
|
||||
*is-invocable-using*<F> is true[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15028)
|
||||
|
||||
*Preconditions*: f is not a null pointer[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15032)
|
||||
|
||||
*Effects*: Initializes*bound-entity* with f, and*thunk-ptr* with the address of a function *thunk* such that*thunk*(*bound-entity*, *call-args*...) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) toinvoke_r<R>(f, *call-args*...)[.](#4.sentence-1)
|
||||
|
||||
[ð](#lib:function_ref,constructor_)
|
||||
|
||||
`template<class F> constexpr function_ref(F&& f) noexcept;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15049)
|
||||
|
||||
Let T be remove_reference_t<F>[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15052)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(6.1)](#6.1)
|
||||
|
||||
remove_cvref_t<F> is not the same type as function_ref,
|
||||
|
||||
- [(6.2)](#6.2)
|
||||
|
||||
is_member_pointer_v<T> is false, and
|
||||
|
||||
- [(6.3)](#6.3)
|
||||
|
||||
*is-invocable-using*<cv T&> is true[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15060)
|
||||
|
||||
*Effects*: Initializes*bound-entity* with addressof(f), and*thunk-ptr* with the address of a function *thunk* such that*thunk*(*bound-entity*, *call-args*...) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) toinvoke_r<R>(static_cast<cv T&>(f), *call-args*...)[.](#7.sentence-1)
|
||||
|
||||
[ð](#lib:function_ref,constructor__)
|
||||
|
||||
`template<auto f> constexpr function_ref(nontype_t<f>) noexcept;
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15077)
|
||||
|
||||
Let F be decltype(f)[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15080)
|
||||
|
||||
*Constraints*: *is-invocable-using*<F> is true[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15084)
|
||||
|
||||
*Mandates*: If is_pointer_v<F> || is_member_pointer_v<F> is true,
|
||||
then f != nullptr is true[.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15089)
|
||||
|
||||
*Effects*: Initializes*bound-entity* with a pointer to an unspecified object or
|
||||
null pointer value, and*thunk-ptr* with the address of a function *thunk* such that*thunk*(*bound-entity*, *call-args*...) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) toinvoke_r<R>(f, *call-args*...)[.](#11.sentence-1)
|
||||
|
||||
[ð](#lib:function_ref,constructor___)
|
||||
|
||||
`template<auto f, class U>
|
||||
constexpr function_ref(nontype_t<f>, U&& obj) noexcept;
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15108)
|
||||
|
||||
Let T be remove_reference_t<U> andF be decltype(f)[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15112)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(13.1)](#13.1)
|
||||
|
||||
is_rvalue_reference_v<U&&> is false, and
|
||||
|
||||
- [(13.2)](#13.2)
|
||||
|
||||
*is-invocable-using*<F, cv T&> is true[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15119)
|
||||
|
||||
*Mandates*: If is_pointer_v<F> || is_member_pointer_v<F> is true,
|
||||
then f != nullptr is true[.](#14.sentence-1)
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15124)
|
||||
|
||||
*Effects*: Initializes*bound-entity* with addressof(obj), and*thunk-ptr* with the address of a function *thunk* such that*thunk*(*bound-entity*, *call-args*...) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) toinvoke_r<R>(f, static_cast<cv T&>(obj), *call-args*...)[.](#15.sentence-1)
|
||||
|
||||
[ð](#lib:function_ref,constructor____)
|
||||
|
||||
`template<auto f, class T>
|
||||
constexpr function_ref(nontype_t<f>, cv T* obj) noexcept;
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15142)
|
||||
|
||||
Let F be decltype(f)[.](#16.sentence-1)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15145)
|
||||
|
||||
*Constraints*: *is-invocable-using*<F, cv T*> is true[.](#17.sentence-1)
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15149)
|
||||
|
||||
*Mandates*: If is_pointer_v<F> || is_member_pointer_v<F> is true,
|
||||
then f != nullptr is true[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15154)
|
||||
|
||||
*Preconditions*: If is_member_pointer_v<F> is true,obj is not a null pointer[.](#19.sentence-1)
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15159)
|
||||
|
||||
*Effects*: Initializes*bound-entity* with obj, and*thunk-ptr* with the address of a function *thunk* such that*thunk*(*bound-entity*, *call-args*...) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) toinvoke_r<R>(f, obj, *call-args*...)[.](#20.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,function_ref)
|
||||
|
||||
`template<class T> function_ref& operator=(T) = delete;
|
||||
`
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15176)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(21.1)](#21.1)
|
||||
|
||||
T is not the same type as function_ref,
|
||||
|
||||
- [(21.2)](#21.2)
|
||||
|
||||
is_pointer_v<T> is false, and
|
||||
|
||||
- [(21.3)](#21.3)
|
||||
|
||||
T is not a specialization of nontype_t[.](#21.sentence-1)
|
||||
85
cppdraft/func/wrap/ref/deduct.md
Normal file
85
cppdraft/func/wrap/ref/deduct.md
Normal file
@@ -0,0 +1,85 @@
|
||||
[func.wrap.ref.deduct]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.ref.deduct)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#ref.deduct)
|
||||
|
||||
#### 22.10.17.6 Non-owning wrapper [[func.wrap.ref]](func.wrap.ref#deduct)
|
||||
|
||||
#### 22.10.17.6.5 Deduction guides [func.wrap.ref.deduct]
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`template<class F>
|
||||
function_ref(F*) -> function_ref<F>;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15207)
|
||||
|
||||
*Constraints*: is_function_v<F> is true[.](#1.sentence-1)
|
||||
|
||||
[ð](#itemdecl:2)
|
||||
|
||||
`template<auto f>
|
||||
function_ref(nontype_t<f>) -> function_ref<see below>;
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15218)
|
||||
|
||||
Let F be remove_pointer_t<decltype(f)>[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15221)
|
||||
|
||||
*Constraints*: is_function_v<F> is true[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15225)
|
||||
|
||||
*Remarks*: The deduced type is function_ref<F>[.](#4.sentence-1)
|
||||
|
||||
[ð](#itemdecl:3)
|
||||
|
||||
`template<auto f, class T>
|
||||
function_ref(nontype_t<f>, T&&) -> function_ref<see below>;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15236)
|
||||
|
||||
Let F be decltype(f)[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15239)
|
||||
|
||||
*Constraints*:
|
||||
|
||||
- [(6.1)](#6.1)
|
||||
|
||||
F is of the formR(G::*)(A...) cv &opt noexcept(E) for a type G, or
|
||||
|
||||
- [(6.2)](#6.2)
|
||||
|
||||
F is of the formM G::* for a type G and an object type M,
|
||||
in which case
|
||||
let R be invoke_result_t<F, T&>,A... be an empty pack, andE be false, or
|
||||
|
||||
- [(6.3)](#6.3)
|
||||
|
||||
F is of the formR(*)(G, A...) noexcept(E) for a type G[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15259)
|
||||
|
||||
*Remarks*: The deduced type is function_ref<R(A...) noexcept(E)>[.](#7.sentence-1)
|
||||
26
cppdraft/func/wrap/ref/general.md
Normal file
26
cppdraft/func/wrap/ref/general.md
Normal file
@@ -0,0 +1,26 @@
|
||||
[func.wrap.ref.general]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.ref.general)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#ref.general)
|
||||
|
||||
#### 22.10.17.6 Non-owning wrapper [[func.wrap.ref]](func.wrap.ref#general)
|
||||
|
||||
#### 22.10.17.6.1 General [func.wrap.ref.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L14922)
|
||||
|
||||
The header provides partial specializations of function_ref for each combination of the possible replacements of
|
||||
the placeholders cv and *noex* where:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
cv is either const or empty, and
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
*noex* is either true or false[.](#1.sentence-1)
|
||||
22
cppdraft/func/wrap/ref/inv.md
Normal file
22
cppdraft/func/wrap/ref/inv.md
Normal file
@@ -0,0 +1,22 @@
|
||||
[func.wrap.ref.inv]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.wrap.ref.inv)
|
||||
|
||||
### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#ref.inv)
|
||||
|
||||
#### 22.10.17.6 Non-owning wrapper [[func.wrap.ref]](func.wrap.ref#inv)
|
||||
|
||||
#### 22.10.17.6.4 Invocation [func.wrap.ref.inv]
|
||||
|
||||
[ð](#lib:operator(),function_ref)
|
||||
|
||||
`R operator()(ArgTypes... args) const noexcept(noex);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15193)
|
||||
|
||||
*Effects*: Equivalent to:return *thunk-ptr*(*bound-entity*, std::forward<ArgTypes>(args)...);
|
||||
Reference in New Issue
Block a user