Init
This commit is contained in:
251
cppdraft/func/bind.md
Normal file
251
cppdraft/func/bind.md
Normal file
@@ -0,0 +1,251 @@
|
||||
[func.bind]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.bind)
|
||||
|
||||
### 22.10.15 Function object binders [func.bind]
|
||||
|
||||
#### [22.10.15.1](#general) General [[func.bind.general]](func.bind.general)
|
||||
|
||||
[1](#general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13332)
|
||||
|
||||
Subclause [func.bind] describes a uniform mechanism for binding
|
||||
arguments of callable objects[.](#general-1.sentence-1)
|
||||
|
||||
#### [22.10.15.2](#isbind) Class template is_bind_expression [[func.bind.isbind]](func.bind.isbind)
|
||||
|
||||
[ð](#lib:is_bind_expression)
|
||||
|
||||
namespace std {template<class T> struct is_bind_expression; // see below}
|
||||
|
||||
[1](#isbind-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13345)
|
||||
|
||||
The class template is_bind_expression can be used to detect function objects
|
||||
generated by bind[.](#isbind-1.sentence-1)
|
||||
|
||||
The function template bind uses is_bind_expression to detect subexpressions[.](#isbind-1.sentence-2)
|
||||
|
||||
[2](#isbind-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13350)
|
||||
|
||||
Specializations of the is_bind_expression template shall meet
|
||||
the [*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2 Requirements [meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements"))[.](#isbind-2.sentence-1)
|
||||
|
||||
The implementation
|
||||
provides a definition that has a base characteristic oftrue_type if T is a type returned from bind,
|
||||
otherwise it has a base characteristic of false_type[.](#isbind-2.sentence-2)
|
||||
|
||||
A program may specialize this template for a program-defined type T to have a base characteristic of true_type to indicate thatT should be treated as a subexpression in a bind call[.](#isbind-2.sentence-3)
|
||||
|
||||
#### [22.10.15.3](#isplace) Class template is_placeholder [[func.bind.isplace]](func.bind.isplace)
|
||||
|
||||
[ð](#lib:is_placeholder)
|
||||
|
||||
namespace std {template<class T> struct is_placeholder; // see below}
|
||||
|
||||
[1](#isplace-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13369)
|
||||
|
||||
The class template is_placeholder can be used to detect the standard placeholders_1, _2, and so on ([[func.bind.place]](#place "22.10.15.5 Placeholders"))[.](#isplace-1.sentence-1)
|
||||
|
||||
The function template bind usesis_placeholder to detect placeholders[.](#isplace-1.sentence-2)
|
||||
|
||||
[2](#isplace-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13386)
|
||||
|
||||
Specializations of the is_placeholder template shall meet
|
||||
the [*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2 Requirements [meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements"))[.](#isplace-2.sentence-1)
|
||||
|
||||
The implementation
|
||||
provides a definition that has the base characteristic ofintegral_constant<int, *J*> if T is the type ofstd::placeholders::_*J*, otherwise it has a
|
||||
base characteristic of integral_constant<int, 0>[.](#isplace-2.sentence-2)
|
||||
|
||||
A program
|
||||
may specialize this template for a program-defined type T to
|
||||
have a base characteristic of integral_constant<int, N> with N > 0 to indicate that T should be
|
||||
treated as a placeholder type[.](#isplace-2.sentence-3)
|
||||
|
||||
#### [22.10.15.4](#bind) Function template bind [[func.bind.bind]](func.bind.bind)
|
||||
|
||||
[1](#bind-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13401)
|
||||
|
||||
In the text that follows:
|
||||
|
||||
- [(1.1)](#bind-1.1)
|
||||
|
||||
g is a value of the result of a bind invocation,
|
||||
|
||||
- [(1.2)](#bind-1.2)
|
||||
|
||||
FD is the type decay_t<F>,
|
||||
|
||||
- [(1.3)](#bind-1.3)
|
||||
|
||||
fd is an lvalue that
|
||||
is a target object of g ([[func.def]](func.def "22.10.3 Definitions")) of type FD direct-non-list-initialized with std::forward<F>(f),
|
||||
|
||||
- [(1.4)](#bind-1.4)
|
||||
|
||||
Ti is the ith type in the template parameter pack BoundArgs,
|
||||
|
||||
- [(1.5)](#bind-1.5)
|
||||
|
||||
TDi is the type decay_t<Ti>,
|
||||
|
||||
- [(1.6)](#bind-1.6)
|
||||
|
||||
ti is the ith argument in the function parameter pack bound_args,
|
||||
|
||||
- [(1.7)](#bind-1.7)
|
||||
|
||||
tdi is a bound argument entity
|
||||
of g ([[func.def]](func.def "22.10.3 Definitions")) of type TDi direct-non-list-initialized with std::forward<Ti>(ti),
|
||||
|
||||
- [(1.8)](#bind-1.8)
|
||||
|
||||
Uj is the jth deduced type of the UnBoundArgs&&... parameter
|
||||
of the argument forwarding call wrapper, and
|
||||
|
||||
- [(1.9)](#bind-1.9)
|
||||
|
||||
uj is the jth argument associated with Uj[.](#bind-1.sentence-1)
|
||||
|
||||
[ð](#lib:bind_)
|
||||
|
||||
`template<class F, class... BoundArgs>
|
||||
constexpr unspecified bind(F&& f, BoundArgs&&... bound_args);
|
||||
template<class R, class F, class... BoundArgs>
|
||||
constexpr unspecified bind(F&& f, BoundArgs&&... bound_args);
|
||||
`
|
||||
|
||||
[2](#bind-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13430)
|
||||
|
||||
*Mandates*: is_constructible_v<FD, F> is true[.](#bind-2.sentence-1)
|
||||
|
||||
For each Ti in BoundArgs, is_constructible_v<TDi, Ti> is true[.](#bind-2.sentence-2)
|
||||
|
||||
[3](#bind-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13435)
|
||||
|
||||
*Preconditions*: FD and each TDi meet
|
||||
the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#bind-3.sentence-1)
|
||||
|
||||
*INVOKE*(fd, w1, w2, …,wN) ([[func.require]](func.require "22.10.4 Requirements")) is a valid expression for some
|
||||
values w1, w2, …, wN, whereN has the value sizeof...(bound_args)[.](#bind-3.sentence-2)
|
||||
|
||||
[4](#bind-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13444)
|
||||
|
||||
*Returns*: An argument forwarding call wrapper g ([[func.require]](func.require "22.10.4 Requirements"))[.](#bind-4.sentence-1)
|
||||
|
||||
A program that attempts to invoke a volatile-qualified g is ill-formed[.](#bind-4.sentence-2)
|
||||
|
||||
When g is not volatile-qualified, invocation ofg(u1, u2, …, uM) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) to*INVOKE*(static_cast<Vfd>(vfd), static_cast<V1>(v1), static_cast<V2>(v2), …, static_cast<VN>(vN)) for the first overload, and*INVOKE*<R>(static_cast<Vfd>(vfd), static_cast<V1>(v1), static_cast<V2>(v2), …, static_cast<VN>(vN)) for the second overload,
|
||||
where the values and types of the target argument vfd and
|
||||
of the bound argumentsv1, v2, …, vN are determined as specified below[.](#bind-4.sentence-3)
|
||||
|
||||
[5](#bind-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13466)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of
|
||||
the state entities of g[.](#bind-5.sentence-1)
|
||||
|
||||
[6](#bind-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13471)
|
||||
|
||||
[*Note [1](#bind-note-1)*:
|
||||
|
||||
If all of FD and TDi meet
|
||||
the requirements of [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"), then
|
||||
the return type meets the requirements of [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]")[.](#bind-6.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[7](#bind-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13479)
|
||||
|
||||
The values of the [*bound arguments*](#def:bound_arguments) v1, v2, …, vN and their
|
||||
corresponding types V1, V2, …, VN depend on the
|
||||
types TDi derived from
|
||||
the call to bind and the
|
||||
cv-qualifiers cv of the call wrapper g as follows:
|
||||
|
||||
- [(7.1)](#bind-7.1)
|
||||
|
||||
if TDi is reference_wrapper<T>, the
|
||||
argument is tdi.get() and its type Vi is T&;
|
||||
|
||||
- [(7.2)](#bind-7.2)
|
||||
|
||||
if the value of is_bind_expression_v<TDi> is true, the argument isstatic_cast<cv TDi&>(tdi)(std::forward<Uj>(uj)...) and its type Vi isinvoke_result_t<cv TDi&, Uj...>&&;
|
||||
|
||||
- [(7.3)](#bind-7.3)
|
||||
|
||||
if the value j of is_placeholder_v<TDi> is not zero, the argument is std::forward<Uj>(uj) and its type Vi is Uj&&;
|
||||
|
||||
- [(7.4)](#bind-7.4)
|
||||
|
||||
otherwise, the value is tdi and its type Vi is cv TDi&[.](#bind-7.sentence-1)
|
||||
|
||||
[8](#bind-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13507)
|
||||
|
||||
The value of the target argument vfd is fd and
|
||||
its corresponding type Vfd is cv FD&[.](#bind-8.sentence-1)
|
||||
|
||||
#### [22.10.15.5](#place) Placeholders [[func.bind.place]](func.bind.place)
|
||||
|
||||
namespace std::placeholders {// *M* is the number of placeholders*see below* _1; *see below* _2;
|
||||
⋮ *see below* _*M*;}
|
||||
|
||||
[1](#place-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13539)
|
||||
|
||||
The number *M* of placeholders isimplementation-defined[.](#place-1.sentence-1)
|
||||
|
||||
[2](#place-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13543)
|
||||
|
||||
All placeholder types meet the [*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "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, and
|
||||
their default constructors and copy/move
|
||||
constructors are constexpr functions that
|
||||
do not throw exceptions[.](#place-2.sentence-1)
|
||||
|
||||
It is implementation-defined whether
|
||||
placeholder types meet the [*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements,
|
||||
but if so, their copy assignment operators are
|
||||
constexpr functions that do not throw exceptions[.](#place-2.sentence-2)
|
||||
|
||||
[3](#place-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13554)
|
||||
|
||||
Placeholders should be defined as:inline constexpr *unspecified* _1{};
|
||||
|
||||
If they are not, they are declared as:extern *unspecified* _1;
|
||||
|
||||
[4](#place-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13565)
|
||||
|
||||
Placeholders are freestanding items ([[freestanding.item]](freestanding.item "16.3.3.7 Freestanding items"))[.](#place-4.sentence-1)
|
||||
145
cppdraft/func/bind/bind.md
Normal file
145
cppdraft/func/bind/bind.md
Normal file
@@ -0,0 +1,145 @@
|
||||
[func.bind.bind]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.bind.bind)
|
||||
|
||||
### 22.10.15 Function object binders [[func.bind]](func.bind#bind)
|
||||
|
||||
#### 22.10.15.4 Function template bind [func.bind.bind]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13401)
|
||||
|
||||
In the text that follows:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
g is a value of the result of a bind invocation,
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
FD is the type decay_t<F>,
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
fd is an lvalue that
|
||||
is a target object of g ([[func.def]](func.def "22.10.3 Definitions")) of type FD direct-non-list-initialized with std::forward<F>(f),
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
Ti is the ith type in the template parameter pack BoundArgs,
|
||||
|
||||
- [(1.5)](#1.5)
|
||||
|
||||
TDi is the type decay_t<Ti>,
|
||||
|
||||
- [(1.6)](#1.6)
|
||||
|
||||
ti is the ith argument in the function parameter pack bound_args,
|
||||
|
||||
- [(1.7)](#1.7)
|
||||
|
||||
tdi is a bound argument entity
|
||||
of g ([[func.def]](func.def "22.10.3 Definitions")) of type TDi direct-non-list-initialized with std::forward<Ti>(ti),
|
||||
|
||||
- [(1.8)](#1.8)
|
||||
|
||||
Uj is the jth deduced type of the UnBoundArgs&&... parameter
|
||||
of the argument forwarding call wrapper, and
|
||||
|
||||
- [(1.9)](#1.9)
|
||||
|
||||
uj is the jth argument associated with Uj[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:bind_)
|
||||
|
||||
`template<class F, class... BoundArgs>
|
||||
constexpr unspecified bind(F&& f, BoundArgs&&... bound_args);
|
||||
template<class R, class F, class... BoundArgs>
|
||||
constexpr unspecified bind(F&& f, BoundArgs&&... bound_args);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13430)
|
||||
|
||||
*Mandates*: is_constructible_v<FD, F> is true[.](#2.sentence-1)
|
||||
|
||||
For each Ti in BoundArgs, is_constructible_v<TDi, Ti> is true[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13435)
|
||||
|
||||
*Preconditions*: FD and each TDi meet
|
||||
the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#3.sentence-1)
|
||||
|
||||
*INVOKE*(fd, w1, w2, …,wN) ([[func.require]](func.require "22.10.4 Requirements")) is a valid expression for some
|
||||
values w1, w2, …, wN, whereN has the value sizeof...(bound_args)[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13444)
|
||||
|
||||
*Returns*: An argument forwarding call wrapper g ([[func.require]](func.require "22.10.4 Requirements"))[.](#4.sentence-1)
|
||||
|
||||
A program that attempts to invoke a volatile-qualified g is ill-formed[.](#4.sentence-2)
|
||||
|
||||
When g is not volatile-qualified, invocation ofg(u1, u2, …, uM) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) to*INVOKE*(static_cast<Vfd>(vfd), static_cast<V1>(v1), static_cast<V2>(v2), …, static_cast<VN>(vN)) for the first overload, and*INVOKE*<R>(static_cast<Vfd>(vfd), static_cast<V1>(v1), static_cast<V2>(v2), …, static_cast<VN>(vN)) for the second overload,
|
||||
where the values and types of the target argument vfd and
|
||||
of the bound argumentsv1, v2, …, vN are determined as specified below[.](#4.sentence-3)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13466)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of
|
||||
the state entities of g[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13471)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
If all of FD and TDi meet
|
||||
the requirements of [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"), then
|
||||
the return type meets the requirements of [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]")[.](#6.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13479)
|
||||
|
||||
The values of the [*bound arguments*](#def:bound_arguments) v1, v2, …, vN and their
|
||||
corresponding types V1, V2, …, VN depend on the
|
||||
types TDi derived from
|
||||
the call to bind and the
|
||||
cv-qualifiers cv of the call wrapper g as follows:
|
||||
|
||||
- [(7.1)](#7.1)
|
||||
|
||||
if TDi is reference_wrapper<T>, the
|
||||
argument is tdi.get() and its type Vi is T&;
|
||||
|
||||
- [(7.2)](#7.2)
|
||||
|
||||
if the value of is_bind_expression_v<TDi> is true, the argument isstatic_cast<cv TDi&>(tdi)(std::forward<Uj>(uj)...) and its type Vi isinvoke_result_t<cv TDi&, Uj...>&&;
|
||||
|
||||
- [(7.3)](#7.3)
|
||||
|
||||
if the value j of is_placeholder_v<TDi> is not zero, the argument is std::forward<Uj>(uj) and its type Vi is Uj&&;
|
||||
|
||||
- [(7.4)](#7.4)
|
||||
|
||||
otherwise, the value is tdi and its type Vi is cv TDi&[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13507)
|
||||
|
||||
The value of the target argument vfd is fd and
|
||||
its corresponding type Vfd is cv FD&[.](#8.sentence-1)
|
||||
16
cppdraft/func/bind/general.md
Normal file
16
cppdraft/func/bind/general.md
Normal file
@@ -0,0 +1,16 @@
|
||||
[func.bind.general]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.bind.general)
|
||||
|
||||
### 22.10.15 Function object binders [[func.bind]](func.bind#general)
|
||||
|
||||
#### 22.10.15.1 General [func.bind.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13332)
|
||||
|
||||
Subclause [[func.bind]](func.bind "22.10.15 Function object binders") describes a uniform mechanism for binding
|
||||
arguments of callable objects[.](#1.sentence-1)
|
||||
35
cppdraft/func/bind/isbind.md
Normal file
35
cppdraft/func/bind/isbind.md
Normal file
@@ -0,0 +1,35 @@
|
||||
[func.bind.isbind]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.bind.isbind)
|
||||
|
||||
### 22.10.15 Function object binders [[func.bind]](func.bind#isbind)
|
||||
|
||||
#### 22.10.15.2 Class template is_bind_expression [func.bind.isbind]
|
||||
|
||||
[ð](#lib:is_bind_expression)
|
||||
|
||||
namespace std {template<class T> struct is_bind_expression; // see below}
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13345)
|
||||
|
||||
The class template is_bind_expression can be used to detect function objects
|
||||
generated by bind[.](#1.sentence-1)
|
||||
|
||||
The function template bind uses is_bind_expression to detect subexpressions[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13350)
|
||||
|
||||
Specializations of the is_bind_expression template shall meet
|
||||
the [*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2 Requirements [meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements"))[.](#2.sentence-1)
|
||||
|
||||
The implementation
|
||||
provides a definition that has a base characteristic oftrue_type if T is a type returned from bind,
|
||||
otherwise it has a base characteristic of false_type[.](#2.sentence-2)
|
||||
|
||||
A program may specialize this template for a program-defined type T to have a base characteristic of true_type to indicate thatT should be treated as a subexpression in a bind call[.](#2.sentence-3)
|
||||
37
cppdraft/func/bind/isplace.md
Normal file
37
cppdraft/func/bind/isplace.md
Normal file
@@ -0,0 +1,37 @@
|
||||
[func.bind.isplace]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.bind.isplace)
|
||||
|
||||
### 22.10.15 Function object binders [[func.bind]](func.bind#isplace)
|
||||
|
||||
#### 22.10.15.3 Class template is_placeholder [func.bind.isplace]
|
||||
|
||||
[ð](#lib:is_placeholder)
|
||||
|
||||
namespace std {template<class T> struct is_placeholder; // see below}
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13369)
|
||||
|
||||
The class template is_placeholder can be used to detect the standard placeholders_1, _2, and so on ([[func.bind.place]](func.bind.place "22.10.15.5 Placeholders"))[.](#1.sentence-1)
|
||||
|
||||
The function template bind usesis_placeholder to detect placeholders[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13386)
|
||||
|
||||
Specializations of the is_placeholder template shall meet
|
||||
the [*Cpp17UnaryTypeTrait*](meta.rqmts#:Cpp17UnaryTypeTrait "21.3.2 Requirements [meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2 Requirements"))[.](#2.sentence-1)
|
||||
|
||||
The implementation
|
||||
provides a definition that has the base characteristic ofintegral_constant<int, *J*> if T is the type ofstd::placeholders::_*J*, otherwise it has a
|
||||
base characteristic of integral_constant<int, 0>[.](#2.sentence-2)
|
||||
|
||||
A program
|
||||
may specialize this template for a program-defined type T to
|
||||
have a base characteristic of integral_constant<int, N> with N > 0 to indicate that T should be
|
||||
treated as a placeholder type[.](#2.sentence-3)
|
||||
174
cppdraft/func/bind/partial.md
Normal file
174
cppdraft/func/bind/partial.md
Normal file
@@ -0,0 +1,174 @@
|
||||
[func.bind.partial]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.bind.partial)
|
||||
|
||||
### 22.10.14 Function templates bind_front and bind_back [func.bind.partial]
|
||||
|
||||
[ð](#lib:bind_front)
|
||||
|
||||
`template<class F, class... Args>
|
||||
constexpr unspecified bind_front(F&& f, Args&&... args);
|
||||
template<class F, class... Args>
|
||||
constexpr unspecified bind_back(F&& f, Args&&... args);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13206)
|
||||
|
||||
Within this subclause:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
g is a value of
|
||||
the result of a bind_front or bind_back invocation,
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
FD is the type decay_t<F>,
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
fd is the target object of g ([[func.def]](func.def "22.10.3 Definitions"))
|
||||
of type FD,
|
||||
direct-non-list-initialized with std::forward<F>(f),
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
BoundArgs is a pack
|
||||
that denotes decay_t<Args>...,
|
||||
|
||||
- [(1.5)](#1.5)
|
||||
|
||||
bound_args is
|
||||
a pack of bound argument entities of g ([[func.def]](func.def "22.10.3 Definitions"))
|
||||
of types BoundArgs...,
|
||||
direct-non-list-initialized with std::forward<Args>(args)...,
|
||||
respectively, and
|
||||
|
||||
- [(1.6)](#1.6)
|
||||
|
||||
call_args is an argument pack used in
|
||||
a function call expression ([[expr.call]](expr.call "7.6.1.3 Function call")) of g[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13226)
|
||||
|
||||
*Mandates*: is_constructible_v<FD, F> && is_move_constructible_v<FD> &&(is_constructible_v<BoundArgs, Args> && ...) &&(is_move_constructible_v<BoundArgs> && ...) is true[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13236)
|
||||
|
||||
*Preconditions*: FD meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#3.sentence-1)
|
||||
|
||||
For each Ti in BoundArgs,
|
||||
if Ti is an object type,Ti meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#3.sentence-2)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13243)
|
||||
|
||||
*Returns*: A perfect forwarding call wrapper ([[func.require]](func.require#term.perfect.forwarding.call.wrapper "22.10.4 Requirements")) g with call pattern:
|
||||
|
||||
- [(4.1)](#4.1)
|
||||
|
||||
invoke(fd, bound_args..., call_args...) for a bind_front invocation, or
|
||||
|
||||
- [(4.2)](#4.2)
|
||||
|
||||
invoke(fd, call_args..., bound_args...) for a bind_back invocation[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13256)
|
||||
|
||||
*Throws*: Any exception thrown by
|
||||
the initialization of the state entities of g ([[func.def]](func.def "22.10.3 Definitions"))[.](#5.sentence-1)
|
||||
|
||||
[ð](#lib:bind_front_)
|
||||
|
||||
`template<auto f, class... Args>
|
||||
constexpr unspecified bind_front(Args&&... args);
|
||||
template<auto f, class... Args>
|
||||
constexpr unspecified bind_back(Args&&... args);
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13272)
|
||||
|
||||
Within this subclause:
|
||||
|
||||
- [(6.1)](#6.1)
|
||||
|
||||
F is the type of f,
|
||||
|
||||
- [(6.2)](#6.2)
|
||||
|
||||
g is a value of the result of
|
||||
a bind_front or bind_back invocation,
|
||||
|
||||
- [(6.3)](#6.3)
|
||||
|
||||
BoundArgs is a pack that denotes decay_t<Args>...,
|
||||
|
||||
- [(6.4)](#6.4)
|
||||
|
||||
bound_args is a pack of bound argument entities ofg ([[func.def]](func.def "22.10.3 Definitions")) of types BoundArgs...,
|
||||
direct-non-list-initialized with std::forward<Args>(args)...,
|
||||
respectively, and
|
||||
|
||||
- [(6.5)](#6.5)
|
||||
|
||||
call_args is an argument pack used in
|
||||
a function call expression ([[expr.call]](expr.call "7.6.1.3 Function call")) of g[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13292)
|
||||
|
||||
*Mandates*:
|
||||
|
||||
- [(7.1)](#7.1)
|
||||
|
||||
(is_constructible_v<BoundArgs, Args> && ...) is true, and
|
||||
|
||||
- [(7.2)](#7.2)
|
||||
|
||||
(is_move_constructible_v<BoundArgs> && ...) is true, and
|
||||
|
||||
- [(7.3)](#7.3)
|
||||
|
||||
if is_pointer_v<F> || is_member_pointer_v<F> is true,
|
||||
then f != nullptr is true[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13304)
|
||||
|
||||
*Preconditions*: For each Ti in BoundArgs,Ti meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13309)
|
||||
|
||||
*Returns*: A perfect forwarding call wrapper ([[func.require]](func.require "22.10.4 Requirements")) g that
|
||||
does not have a target object, and has the call pattern:
|
||||
|
||||
- [(9.1)](#9.1)
|
||||
|
||||
invoke(f, bound_args..., call_args...) for a bind_front invocation, or
|
||||
|
||||
- [(9.2)](#9.2)
|
||||
|
||||
invoke(f, call_args..., bound_args...) for a bind_back invocation[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13322)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of bound_args[.](#10.sentence-1)
|
||||
46
cppdraft/func/bind/place.md
Normal file
46
cppdraft/func/bind/place.md
Normal file
@@ -0,0 +1,46 @@
|
||||
[func.bind.place]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.bind.place)
|
||||
|
||||
### 22.10.15 Function object binders [[func.bind]](func.bind#place)
|
||||
|
||||
#### 22.10.15.5 Placeholders [func.bind.place]
|
||||
|
||||
namespace std::placeholders {// *M* is the number of placeholders*see below* _1; *see below* _2;
|
||||
⋮ *see below* _*M*;}
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13539)
|
||||
|
||||
The number *M* of placeholders isimplementation-defined[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13543)
|
||||
|
||||
All placeholder types meet the [*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "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, and
|
||||
their default constructors and copy/move
|
||||
constructors are constexpr functions that
|
||||
do not throw exceptions[.](#2.sentence-1)
|
||||
|
||||
It is implementation-defined whether
|
||||
placeholder types meet the [*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements,
|
||||
but if so, their copy assignment operators are
|
||||
constexpr functions that do not throw exceptions[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13554)
|
||||
|
||||
Placeholders should be defined as:inline constexpr *unspecified* _1{};
|
||||
|
||||
If they are not, they are declared as:extern *unspecified* _1;
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13565)
|
||||
|
||||
Placeholders are freestanding items ([[freestanding.item]](freestanding.item "16.3.3.7 Freestanding items"))[.](#4.sentence-1)
|
||||
69
cppdraft/func/def.md
Normal file
69
cppdraft/func/def.md
Normal file
@@ -0,0 +1,69 @@
|
||||
[func.def]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.def)
|
||||
|
||||
### 22.10.3 Definitions [func.def]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11465)
|
||||
|
||||
The following definitions apply to this Clause:
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11468)
|
||||
|
||||
A [*call signature*](#def:call_signature "22.10.3 Definitions [func.def]") is the name of a return type followed by a
|
||||
parenthesized comma-separated list of zero or more argument types[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11472)
|
||||
|
||||
A [*callable type*](#def:type,callable "22.10.3 Definitions [func.def]") is a function object type ([[function.objects]](function.objects "22.10 Function objects")) or a pointer to member[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11475)
|
||||
|
||||
A [*callable object*](#def:object,callable "22.10.3 Definitions [func.def]") is an object of a callable type[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11478)
|
||||
|
||||
A [*call wrapper type*](#def:call_wrapper,type "22.10.3 Definitions [func.def]") is a type that holds a callable object
|
||||
and supports a call operation that forwards to that object[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11482)
|
||||
|
||||
A [*call wrapper*](#def:call_wrapper "22.10.3 Definitions [func.def]") is an object of a call wrapper type[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11485)
|
||||
|
||||
A [*target object*](#def:target_object "22.10.3 Definitions [func.def]") is the callable object held by a call wrapper[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11488)
|
||||
|
||||
A call wrapper type may additionally hold
|
||||
a sequence of objects and references
|
||||
that may be passed as arguments to the target object[.](#8.sentence-1)
|
||||
|
||||
These entities are collectively referred to
|
||||
as [*bound argument entities*](#def:bound_argument_entity "22.10.3 Definitions [func.def]")[.](#8.sentence-2)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11495)
|
||||
|
||||
The target object and bound argument entities of the call wrapper are
|
||||
collectively referred to as [*state entities*](#def:state_entity "22.10.3 Definitions [func.def]")[.](#9.sentence-1)
|
||||
26
cppdraft/func/identity.md
Normal file
26
cppdraft/func/identity.md
Normal file
@@ -0,0 +1,26 @@
|
||||
[func.identity]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.identity)
|
||||
|
||||
### 22.10.12 Class identity [func.identity]
|
||||
|
||||
[ð](#lib:identity)
|
||||
|
||||
`struct identity {
|
||||
template<class T>
|
||||
constexpr T&& operator()(T&& t) const noexcept;
|
||||
|
||||
using is_transparent = unspecified;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
constexpr T&& operator()(T&& t) const noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13119)
|
||||
|
||||
*Effects*: Equivalent to: return std::forward<T>(t);
|
||||
45
cppdraft/func/invoke.md
Normal file
45
cppdraft/func/invoke.md
Normal file
@@ -0,0 +1,45 @@
|
||||
[func.invoke]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.invoke)
|
||||
|
||||
### 22.10.5 invoke functions [func.invoke]
|
||||
|
||||
[ð](#lib:invoke)
|
||||
|
||||
`template<class F, class... Args>
|
||||
constexpr invoke_result_t<F, Args...> invoke(F&& f, Args&&... args)
|
||||
noexcept(is_nothrow_invocable_v<F, Args...>);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11626)
|
||||
|
||||
*Constraints*: is_invocable_v<F, Args...> is true[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11630)
|
||||
|
||||
*Returns*: *INVOKE*(std::forward<F>(f), std::forward<Args>(args)...) ([[func.require]](func.require "22.10.4 Requirements"))[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:invoke_r)
|
||||
|
||||
`template<class R, class F, class... Args>
|
||||
constexpr R invoke_r(F&& f, Args&&... args)
|
||||
noexcept(is_nothrow_invocable_r_v<R, F, Args...>);
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11643)
|
||||
|
||||
*Constraints*: is_invocable_r_v<R, F, Args...> is true[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11647)
|
||||
|
||||
*Returns*: *INVOKE*<R>(std::forward<F>(f), std::forward<Args>(args)...) ([[func.require]](func.require "22.10.4 Requirements"))[.](#4.sentence-1)
|
||||
19
cppdraft/func/memfn.md
Normal file
19
cppdraft/func/memfn.md
Normal file
@@ -0,0 +1,19 @@
|
||||
[func.memfn]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.memfn)
|
||||
|
||||
### 22.10.16 Function template mem_fn [func.memfn]
|
||||
|
||||
[ð](#lib:mem_fn)
|
||||
|
||||
`template<class R, class T> constexpr unspecified mem_fn(R T::* pm) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13578)
|
||||
|
||||
*Returns*: A simple call wrapper ([[func.require]](func.require#term.simple.call.wrapper "22.10.4 Requirements")) fn with call pattern invoke(pmd, call_args...), wherepmd is the target object of fn of type R T::* direct-non-list-initialized with pm, andcall_args is an argument pack
|
||||
used in a function call expression ([[expr.call]](expr.call "7.6.1.3 Function call")) of fn[.](#1.sentence-1)
|
||||
100
cppdraft/func/not/fn.md
Normal file
100
cppdraft/func/not/fn.md
Normal file
@@ -0,0 +1,100 @@
|
||||
[func.not.fn]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.not.fn)
|
||||
|
||||
### 22.10.13 Function template not_fn [func.not.fn]
|
||||
|
||||
[ð](#lib:not_fn)
|
||||
|
||||
`template<class F> constexpr unspecified not_fn(F&& f);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13133)
|
||||
|
||||
In the text that follows:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
g is a value of the result of a not_fn invocation,
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
FD is the type decay_t<F>,
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
fd is the target object of g ([[func.def]](func.def "22.10.3 Definitions"))
|
||||
of type FD,
|
||||
direct-non-list-initialized with std::forward<F>(f),
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
call_args is an argument pack
|
||||
used in a function call expression ([[expr.call]](expr.call "7.6.1.3 Function call")) of g[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13145)
|
||||
|
||||
*Mandates*: is_constructible_v<FD, F> && is_move_constructible_v<FD> is true[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13150)
|
||||
|
||||
*Preconditions*: FD meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13154)
|
||||
|
||||
*Returns*: A perfect forwarding call wrapper ([[func.require]](func.require#term.perfect.forwarding.call.wrapper "22.10.4 Requirements")) g with call pattern !invoke(fd, call_args...)[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13159)
|
||||
|
||||
*Throws*: Any exception thrown by the initialization of fd[.](#5.sentence-1)
|
||||
|
||||
[ð](#lib:not_fn_)
|
||||
|
||||
`template<auto f> constexpr unspecified not_fn() noexcept;
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13170)
|
||||
|
||||
In the text that follows:
|
||||
|
||||
- [(6.1)](#6.1)
|
||||
|
||||
F is the type of f,
|
||||
|
||||
- [(6.2)](#6.2)
|
||||
|
||||
g is a value of the result of a not_fn invocation,
|
||||
|
||||
- [(6.3)](#6.3)
|
||||
|
||||
call_args is an argument pack
|
||||
used in a function call expression ([[expr.call]](expr.call "7.6.1.3 Function call")) of g[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13182)
|
||||
|
||||
*Mandates*: If is_pointer_v<F> || is_member_pointer_v<F> is true,
|
||||
then f != nullptr is true[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13187)
|
||||
|
||||
*Returns*: A perfect forwarding call wrapper ([[func.require]](func.require "22.10.4 Requirements")) g that
|
||||
does not have state entities, and
|
||||
has the call pattern !invoke(f, call_args...)[.](#8.sentence-1)
|
||||
136
cppdraft/func/require.md
Normal file
136
cppdraft/func/require.md
Normal file
@@ -0,0 +1,136 @@
|
||||
[func.require]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.require)
|
||||
|
||||
### 22.10.4 Requirements [func.require]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11501)
|
||||
|
||||
Define *INVOKE*(f, t1, t2, …, tN) as follows:
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
(t1.*f)(t2, …, tN) when f is a pointer to a
|
||||
member function of a class T andis_same_v<T, remove_cvref_t<decltype(t1)>> ||is_base_of_v<T, remove_cvref_t<decltype(t1)>> is true;
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
(t1.get().*f)(t2, …, tN) when f is a pointer to a
|
||||
member function of a class T and remove_cvref_t<decltype(t1)> is a specialization of reference_wrapper;
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
((*t1).*f)(t2, …, tN) when f is a pointer to a
|
||||
member function of a class T and t1 does not satisfy the previous two items;
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
t1.*f when N=1 and f is a pointer to
|
||||
data member of a class T andis_same_v<T, remove_cvref_t<decltype(t1)>> ||is_base_of_v<T, remove_cvref_t<decltype(t1)>> is true;
|
||||
|
||||
- [(1.5)](#1.5)
|
||||
|
||||
t1.get().*f when N=1 and f is a pointer to
|
||||
data member of a class T and remove_cvref_t<decltype(t1)> is a specialization of reference_wrapper;
|
||||
|
||||
- [(1.6)](#1.6)
|
||||
|
||||
(*t1).*f when N=1 and f is a pointer to
|
||||
data member of a class T and t1 does not satisfy the previous two items;
|
||||
|
||||
- [(1.7)](#1.7)
|
||||
|
||||
f(t1, t2, …, tN) in all other cases[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11537)
|
||||
|
||||
Define *INVOKE*<R>(f, t1, t2, …, tN) asstatic_cast<void>(*INVOKE*(f, t1, t2, …, tN)) if R is cv void, otherwise*INVOKE*(f, t1, t2, …, tN) implicitly converted
|
||||
to R[.](#2.sentence-1)
|
||||
|
||||
Ifreference_converts_from_temporary_v<R, decltype(*INVOKE*(f, t1, t2, …, tN))> is true,*INVOKE*<R>(f, t1, t2, …, tN) is ill-formed[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11550)
|
||||
|
||||
Every call wrapper ([[func.def]](func.def "22.10.3 Definitions")) meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#3.sentence-1)
|
||||
|
||||
An [*argument forwarding call wrapper*](#def:argument_forwarding_call_wrapper "22.10.4 Requirements [func.require]") is a
|
||||
call wrapper that can be called with an arbitrary argument list
|
||||
and delivers the arguments to the target object as references[.](#3.sentence-2)
|
||||
|
||||
This forwarding step delivers rvalue arguments as rvalue references
|
||||
and lvalue arguments as lvalue references[.](#3.sentence-3)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
In a typical implementation, argument forwarding call wrappers have
|
||||
an overloaded function call operator of the formtemplate<class... UnBoundArgs>constexpr R operator()(UnBoundArgs&&... unbound_args) *cv-qual*;
|
||||
|
||||
â *end note*]
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11570)
|
||||
|
||||
A [*perfect forwarding call wrapper*](#def:call_wrapper,perfect_forwarding "22.10.4 Requirements [func.require]") is
|
||||
an argument forwarding call wrapper
|
||||
that forwards its state entities to the underlying call expression[.](#4.sentence-1)
|
||||
|
||||
This forwarding step delivers a state entity of type T as cv T& when the call is performed on an lvalue of the call wrapper type and
|
||||
as cv T&& otherwise,
|
||||
where cv represents the cv-qualifiers of the call wrapper and
|
||||
where cv shall be neither volatile nor const volatile[.](#4.sentence-2)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11582)
|
||||
|
||||
A [*call pattern*](#def:call_pattern "22.10.4 Requirements [func.require]") defines the semantics of invoking
|
||||
a perfect forwarding call wrapper[.](#5.sentence-1)
|
||||
|
||||
A postfix call performed on a perfect forwarding call wrapper is
|
||||
expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 expression-equivalent")) to
|
||||
an expression e determined from its call pattern cp by replacing all occurrences
|
||||
of the arguments of the call wrapper and its state entities
|
||||
with references as described in the corresponding forwarding steps[.](#5.sentence-2)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11592)
|
||||
|
||||
A [*simple call wrapper*](#def:simple_call_wrapper "22.10.4 Requirements [func.require]") is a perfect forwarding call wrapper that meets
|
||||
the [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and [*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements
|
||||
and whose copy constructor, move constructor, and assignment operators
|
||||
are constexpr functions that do not throw exceptions[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11599)
|
||||
|
||||
The copy/move constructor of an argument forwarding call wrapper has
|
||||
the same apparent semantics
|
||||
as if memberwise copy/move of its state entities
|
||||
were performed ([[class.copy.ctor]](class.copy.ctor "11.4.5.3 Copy/move constructors"))[.](#7.sentence-1)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
This implies that each of the copy/move constructors has
|
||||
the same exception-specification as
|
||||
the corresponding implicit definition and is declared as constexpr if the corresponding implicit definition would be considered to be constexpr[.](#7.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L11611)
|
||||
|
||||
Argument forwarding call wrappers returned by
|
||||
a given standard library function template have the same type
|
||||
if the types of their corresponding state entities are the same[.](#8.sentence-1)
|
||||
307
cppdraft/func/search.md
Normal file
307
cppdraft/func/search.md
Normal file
@@ -0,0 +1,307 @@
|
||||
[func.search]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.search)
|
||||
|
||||
### 22.10.18 Searchers [func.search]
|
||||
|
||||
#### [22.10.18.1](#general) General [[func.search.general]](func.search.general)
|
||||
|
||||
[1](#general-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15269)
|
||||
|
||||
Subclause [func.search] provides function object types ([[function.objects]](function.objects "22.10 Function objects")) for
|
||||
operations that search for a sequence [pat_first, pat_last) in another
|
||||
sequence [first, last) that is provided to the object's function call
|
||||
operator[.](#general-1.sentence-1)
|
||||
|
||||
The first sequence (the pattern to be searched for) is provided to
|
||||
the object's constructor, and the second (the sequence to be searched) is
|
||||
provided to the function call operator[.](#general-1.sentence-2)
|
||||
|
||||
[2](#general-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15277)
|
||||
|
||||
Each specialization of a class template specified in [func.search]
|
||||
shall meet the [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and [*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#general-2.sentence-1)
|
||||
|
||||
Template parameters named
|
||||
|
||||
- [(2.1)](#general-2.1)
|
||||
|
||||
ForwardIterator,
|
||||
|
||||
- [(2.2)](#general-2.2)
|
||||
|
||||
ForwardIterator1,
|
||||
|
||||
- [(2.3)](#general-2.3)
|
||||
|
||||
ForwardIterator2,
|
||||
|
||||
- [(2.4)](#general-2.4)
|
||||
|
||||
RandomAccessIterator,
|
||||
|
||||
- [(2.5)](#general-2.5)
|
||||
|
||||
RandomAccessIterator1,
|
||||
|
||||
- [(2.6)](#general-2.6)
|
||||
|
||||
RandomAccessIterator2, and
|
||||
|
||||
- [(2.7)](#general-2.7)
|
||||
|
||||
BinaryPredicate
|
||||
|
||||
of templates specified in
|
||||
[func.search] shall meet the same requirements and semantics as
|
||||
specified in [[algorithms.general]](algorithms.general "26.1 General")[.](#general-2.sentence-2)
|
||||
|
||||
Template parameters named Hash shall meet the [*Cpp17Hash*](hash.requirements#:Cpp17Hash "16.4.4.5 Cpp17Hash requirements [hash.requirements]") requirements (Table [37](hash.requirements#tab:cpp17.hash "Table 37: Cpp17Hash requirements"))[.](#general-2.sentence-3)
|
||||
|
||||
[3](#general-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15296)
|
||||
|
||||
The Boyer-Moore searcher implements the Boyer-Moore search algorithm[.](#general-3.sentence-1)
|
||||
|
||||
The Boyer-Moore-Horspool searcher implements the Boyer-Moore-Horspool search algorithm[.](#general-3.sentence-2)
|
||||
|
||||
In general, the Boyer-Moore searcher will use more memory and give better runtime performance than Boyer-Moore-Horspool[.](#general-3.sentence-3)
|
||||
|
||||
#### [22.10.18.2](#default) Class template default_searcher [[func.search.default]](func.search.default)
|
||||
|
||||
[ð](#lib:default_searcher)
|
||||
|
||||
namespace std {template<class ForwardIterator1, class BinaryPredicate = equal_to<>>class default_searcher {public:constexpr default_searcher(ForwardIterator1 pat_first, ForwardIterator1 pat_last,
|
||||
BinaryPredicate pred = BinaryPredicate()); template<class ForwardIterator2>constexpr pair<ForwardIterator2, ForwardIterator2>operator()(ForwardIterator2 first, ForwardIterator2 last) const; private: ForwardIterator1 pat_first_; // *exposition only* ForwardIterator1 pat_last_; // *exposition only* BinaryPredicate pred_; // *exposition only*};}
|
||||
|
||||
[ð](#lib:default_searcher,constructor)
|
||||
|
||||
`constexpr default_searcher(ForwardIterator1 pat_first, ForwardIterator1 pat_last,
|
||||
BinaryPredicate pred = BinaryPredicate());
|
||||
`
|
||||
|
||||
[1](#default-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15331)
|
||||
|
||||
*Effects*: Constructs a default_searcher object, initializing pat_first_ with pat_first, pat_last_ with pat_last, andpred_ with pred[.](#default-1.sentence-1)
|
||||
|
||||
[2](#default-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15338)
|
||||
|
||||
*Throws*: Any exception thrown by the copy constructor of BinaryPredicate orForwardIterator1[.](#default-2.sentence-1)
|
||||
|
||||
[ð](#lib:operator(),default_searcher)
|
||||
|
||||
`template<class ForwardIterator2>
|
||||
constexpr pair<ForwardIterator2, ForwardIterator2>
|
||||
operator()(ForwardIterator2 first, ForwardIterator2 last) const;
|
||||
`
|
||||
|
||||
[3](#default-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15352)
|
||||
|
||||
*Effects*: Returns a pair of iterators i and j such that
|
||||
|
||||
- [(3.1)](#default-3.1)
|
||||
|
||||
i == search(first, last, pat_first_, pat_last_, pred_), and
|
||||
|
||||
- [(3.2)](#default-3.2)
|
||||
|
||||
if i == last, then j == last,
|
||||
otherwise j == next(i, distance(pat_first_, pat_last_))[.](#default-3.sentence-1)
|
||||
|
||||
#### [22.10.18.3](#bm) Class template boyer_moore_searcher [[func.search.bm]](func.search.bm)
|
||||
|
||||
[ð](#lib:boyer_moore_searcher)
|
||||
|
||||
namespace std {template<class RandomAccessIterator1, class Hash = hash<typename iterator_traits<RandomAccessIterator1>::value_type>, class BinaryPredicate = equal_to<>>class boyer_moore_searcher {public: boyer_moore_searcher(RandomAccessIterator1 pat_first,
|
||||
RandomAccessIterator1 pat_last,
|
||||
Hash hf = Hash(),
|
||||
BinaryPredicate pred = BinaryPredicate()); template<class RandomAccessIterator2> pair<RandomAccessIterator2, RandomAccessIterator2>operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; private: RandomAccessIterator1 pat_first_; // *exposition only* RandomAccessIterator1 pat_last_; // *exposition only* Hash hash_; // *exposition only* BinaryPredicate pred_; // *exposition only*};}
|
||||
|
||||
[ð](#lib:boyer_moore_searcher,constructor)
|
||||
|
||||
`boyer_moore_searcher(RandomAccessIterator1 pat_first,
|
||||
RandomAccessIterator1 pat_last,
|
||||
Hash hf = Hash(),
|
||||
BinaryPredicate pred = BinaryPredicate());
|
||||
`
|
||||
|
||||
[1](#bm-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15399)
|
||||
|
||||
*Preconditions*: The value type of RandomAccessIterator1 meets
|
||||
the [*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"), and[*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#bm-1.sentence-1)
|
||||
|
||||
[2](#bm-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15406)
|
||||
|
||||
Let V be iterator_traits<RandomAccessIterator1>::value_type[.](#bm-2.sentence-1)
|
||||
|
||||
For any two values A and B of type V,
|
||||
if pred(A, B) == true, then hf(A) == hf(B) is true[.](#bm-2.sentence-2)
|
||||
|
||||
[3](#bm-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15411)
|
||||
|
||||
*Effects*: Initializespat_first_ with pat_first,pat_last_ with pat_last,hash_ with hf, andpred_ with pred[.](#bm-3.sentence-1)
|
||||
|
||||
[4](#bm-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15420)
|
||||
|
||||
*Throws*: Any exception thrown by the copy constructor of RandomAccessIterator1,
|
||||
or by the default constructor, copy constructor, or the copy assignment operator of the value type of RandomAccessIterator1,
|
||||
or the copy constructor or operator() of BinaryPredicate or Hash[.](#bm-4.sentence-1)
|
||||
|
||||
May throw bad_alloc if additional memory needed for internal data structures cannot be allocated[.](#bm-4.sentence-2)
|
||||
|
||||
[ð](#lib:operator(),boyer_moore_searcher)
|
||||
|
||||
`template<class RandomAccessIterator2>
|
||||
pair<RandomAccessIterator2, RandomAccessIterator2>
|
||||
operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
|
||||
`
|
||||
|
||||
[5](#bm-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15436)
|
||||
|
||||
*Mandates*: RandomAccessIterator1 and RandomAccessIterator2 have the same value type[.](#bm-5.sentence-1)
|
||||
|
||||
[6](#bm-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15441)
|
||||
|
||||
*Effects*: Finds a subsequence of equal values in a sequence[.](#bm-6.sentence-1)
|
||||
|
||||
[7](#bm-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15445)
|
||||
|
||||
*Returns*: A pair of iterators i and j such that
|
||||
|
||||
- [(7.1)](#bm-7.1)
|
||||
|
||||
i is the first iterator
|
||||
in the range [first, last - (pat_last_ - pat_first_)) such that
|
||||
for every non-negative integer n less than pat_last_ - pat_first_ the following condition holds:pred(*(i + n), *(pat_first_ + n)) != false, and
|
||||
|
||||
- [(7.2)](#bm-7.2)
|
||||
|
||||
j == next(i, distance(pat_first_, pat_last_))[.](#bm-7.sentence-1)
|
||||
|
||||
Returns make_pair(first, first) if [pat_first_, pat_last_) is empty,
|
||||
otherwise returns make_pair(last, last) if no such iterator is found[.](#bm-7.sentence-2)
|
||||
|
||||
[8](#bm-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15459)
|
||||
|
||||
*Complexity*: At most (last - first) * (pat_last_ - pat_first_) applications of the predicate[.](#bm-8.sentence-1)
|
||||
|
||||
#### [22.10.18.4](#bmh) Class template boyer_moore_horspool_searcher [[func.search.bmh]](func.search.bmh)
|
||||
|
||||
[ð](#lib:boyer_moore_horspool_searcher)
|
||||
|
||||
namespace std {template<class RandomAccessIterator1, class Hash = hash<typename iterator_traits<RandomAccessIterator1>::value_type>, class BinaryPredicate = equal_to<>>class boyer_moore_horspool_searcher {public: boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first,
|
||||
RandomAccessIterator1 pat_last,
|
||||
Hash hf = Hash(),
|
||||
BinaryPredicate pred = BinaryPredicate()); template<class RandomAccessIterator2> pair<RandomAccessIterator2, RandomAccessIterator2>operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; private: RandomAccessIterator1 pat_first_; // *exposition only* RandomAccessIterator1 pat_last_; // *exposition only* Hash hash_; // *exposition only* BinaryPredicate pred_; // *exposition only*};}
|
||||
|
||||
[ð](#lib:boyer_moore_horspool_searcher,constructor)
|
||||
|
||||
`boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first,
|
||||
RandomAccessIterator1 pat_last,
|
||||
Hash hf = Hash(),
|
||||
BinaryPredicate pred = BinaryPredicate());
|
||||
`
|
||||
|
||||
[1](#bmh-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15501)
|
||||
|
||||
*Preconditions*: The value type of RandomAccessIterator1 meets the [*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"), and [*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#bmh-1.sentence-1)
|
||||
|
||||
[2](#bmh-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15506)
|
||||
|
||||
Let V be iterator_traits<RandomAccessIterator1>::value_type[.](#bmh-2.sentence-1)
|
||||
|
||||
For any two values A and B of type V,
|
||||
if pred(A, B) == true, then hf(A) == hf(B) is true[.](#bmh-2.sentence-2)
|
||||
|
||||
[3](#bmh-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15511)
|
||||
|
||||
*Effects*: Initializespat_first_ with pat_first,pat_last_ with pat_last,hash_ with hf, andpred_ with pred[.](#bmh-3.sentence-1)
|
||||
|
||||
[4](#bmh-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15520)
|
||||
|
||||
*Throws*: Any exception thrown by the copy constructor of RandomAccessIterator1,
|
||||
or by the default constructor, copy constructor, or the copy assignment operator of the value type of RandomAccessIterator1,
|
||||
or the copy constructor or operator() of BinaryPredicate or Hash[.](#bmh-4.sentence-1)
|
||||
|
||||
May throw bad_alloc if additional memory needed for internal data structures cannot be allocated[.](#bmh-4.sentence-2)
|
||||
|
||||
[ð](#lib:operator(),boyer_moore_horspool_searcher)
|
||||
|
||||
`template<class RandomAccessIterator2>
|
||||
pair<RandomAccessIterator2, RandomAccessIterator2>
|
||||
operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
|
||||
`
|
||||
|
||||
[5](#bmh-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15536)
|
||||
|
||||
*Mandates*: RandomAccessIterator1 and RandomAccessIterator2 have the same value type[.](#bmh-5.sentence-1)
|
||||
|
||||
[6](#bmh-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15541)
|
||||
|
||||
*Effects*: Finds a subsequence of equal values in a sequence[.](#bmh-6.sentence-1)
|
||||
|
||||
[7](#bmh-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15545)
|
||||
|
||||
*Returns*: A pair of iterators i and j such that
|
||||
|
||||
- [(7.1)](#bmh-7.1)
|
||||
|
||||
i is the first iterator in the range
|
||||
[first, last - (pat_last_ - pat_first_)) such that
|
||||
for every non-negative integer n less than pat_last_ - pat_first_ the following condition holds:pred(*(i + n), *(pat_first_ + n)) != false, and
|
||||
|
||||
- [(7.2)](#bmh-7.2)
|
||||
|
||||
j == next(i, distance(pat_first_, pat_last_))[.](#bmh-7.sentence-1)
|
||||
|
||||
Returns make_pair(first, first) if [pat_first_, pat_last_) is empty,
|
||||
otherwise returns make_pair(last, last) if no such iterator is found[.](#bmh-7.sentence-2)
|
||||
|
||||
[8](#bmh-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15559)
|
||||
|
||||
*Complexity*: At most (last - first) * (pat_last_ - pat_first_) applications of the predicate[.](#bmh-8.sentence-1)
|
||||
100
cppdraft/func/search/bm.md
Normal file
100
cppdraft/func/search/bm.md
Normal file
@@ -0,0 +1,100 @@
|
||||
[func.search.bm]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.search.bm)
|
||||
|
||||
### 22.10.18 Searchers [[func.search]](func.search#bm)
|
||||
|
||||
#### 22.10.18.3 Class template boyer_moore_searcher [func.search.bm]
|
||||
|
||||
[ð](#lib:boyer_moore_searcher)
|
||||
|
||||
namespace std {template<class RandomAccessIterator1, class Hash = hash<typename iterator_traits<RandomAccessIterator1>::value_type>, class BinaryPredicate = equal_to<>>class boyer_moore_searcher {public: boyer_moore_searcher(RandomAccessIterator1 pat_first,
|
||||
RandomAccessIterator1 pat_last,
|
||||
Hash hf = Hash(),
|
||||
BinaryPredicate pred = BinaryPredicate()); template<class RandomAccessIterator2> pair<RandomAccessIterator2, RandomAccessIterator2>operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; private: RandomAccessIterator1 pat_first_; // *exposition only* RandomAccessIterator1 pat_last_; // *exposition only* Hash hash_; // *exposition only* BinaryPredicate pred_; // *exposition only*};}
|
||||
|
||||
[ð](#lib:boyer_moore_searcher,constructor)
|
||||
|
||||
`boyer_moore_searcher(RandomAccessIterator1 pat_first,
|
||||
RandomAccessIterator1 pat_last,
|
||||
Hash hf = Hash(),
|
||||
BinaryPredicate pred = BinaryPredicate());
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15399)
|
||||
|
||||
*Preconditions*: The value type of RandomAccessIterator1 meets
|
||||
the [*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"), and[*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15406)
|
||||
|
||||
Let V be iterator_traits<RandomAccessIterator1>::value_type[.](#2.sentence-1)
|
||||
|
||||
For any two values A and B of type V,
|
||||
if pred(A, B) == true, then hf(A) == hf(B) is true[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15411)
|
||||
|
||||
*Effects*: Initializespat_first_ with pat_first,pat_last_ with pat_last,hash_ with hf, andpred_ with pred[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15420)
|
||||
|
||||
*Throws*: Any exception thrown by the copy constructor of RandomAccessIterator1,
|
||||
or by the default constructor, copy constructor, or the copy assignment operator of the value type of RandomAccessIterator1,
|
||||
or the copy constructor or operator() of BinaryPredicate or Hash[.](#4.sentence-1)
|
||||
|
||||
May throw bad_alloc if additional memory needed for internal data structures cannot be allocated[.](#4.sentence-2)
|
||||
|
||||
[ð](#lib:operator(),boyer_moore_searcher)
|
||||
|
||||
`template<class RandomAccessIterator2>
|
||||
pair<RandomAccessIterator2, RandomAccessIterator2>
|
||||
operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15436)
|
||||
|
||||
*Mandates*: RandomAccessIterator1 and RandomAccessIterator2 have the same value type[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15441)
|
||||
|
||||
*Effects*: Finds a subsequence of equal values in a sequence[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15445)
|
||||
|
||||
*Returns*: A pair of iterators i and j such that
|
||||
|
||||
- [(7.1)](#7.1)
|
||||
|
||||
i is the first iterator
|
||||
in the range [first, last - (pat_last_ - pat_first_)) such that
|
||||
for every non-negative integer n less than pat_last_ - pat_first_ the following condition holds:pred(*(i + n), *(pat_first_ + n)) != false, and
|
||||
|
||||
- [(7.2)](#7.2)
|
||||
|
||||
j == next(i, distance(pat_first_, pat_last_))[.](#7.sentence-1)
|
||||
|
||||
Returns make_pair(first, first) if [pat_first_, pat_last_) is empty,
|
||||
otherwise returns make_pair(last, last) if no such iterator is found[.](#7.sentence-2)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15459)
|
||||
|
||||
*Complexity*: At most (last - first) * (pat_last_ - pat_first_) applications of the predicate[.](#8.sentence-1)
|
||||
99
cppdraft/func/search/bmh.md
Normal file
99
cppdraft/func/search/bmh.md
Normal file
@@ -0,0 +1,99 @@
|
||||
[func.search.bmh]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.search.bmh)
|
||||
|
||||
### 22.10.18 Searchers [[func.search]](func.search#bmh)
|
||||
|
||||
#### 22.10.18.4 Class template boyer_moore_horspool_searcher [func.search.bmh]
|
||||
|
||||
[ð](#lib:boyer_moore_horspool_searcher)
|
||||
|
||||
namespace std {template<class RandomAccessIterator1, class Hash = hash<typename iterator_traits<RandomAccessIterator1>::value_type>, class BinaryPredicate = equal_to<>>class boyer_moore_horspool_searcher {public: boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first,
|
||||
RandomAccessIterator1 pat_last,
|
||||
Hash hf = Hash(),
|
||||
BinaryPredicate pred = BinaryPredicate()); template<class RandomAccessIterator2> pair<RandomAccessIterator2, RandomAccessIterator2>operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; private: RandomAccessIterator1 pat_first_; // *exposition only* RandomAccessIterator1 pat_last_; // *exposition only* Hash hash_; // *exposition only* BinaryPredicate pred_; // *exposition only*};}
|
||||
|
||||
[ð](#lib:boyer_moore_horspool_searcher,constructor)
|
||||
|
||||
`boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first,
|
||||
RandomAccessIterator1 pat_last,
|
||||
Hash hf = Hash(),
|
||||
BinaryPredicate pred = BinaryPredicate());
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15501)
|
||||
|
||||
*Preconditions*: The value type of RandomAccessIterator1 meets the [*Cpp17DefaultConstructible*](utility.arg.requirements#:Cpp17DefaultConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"),[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"), and [*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15506)
|
||||
|
||||
Let V be iterator_traits<RandomAccessIterator1>::value_type[.](#2.sentence-1)
|
||||
|
||||
For any two values A and B of type V,
|
||||
if pred(A, B) == true, then hf(A) == hf(B) is true[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15511)
|
||||
|
||||
*Effects*: Initializespat_first_ with pat_first,pat_last_ with pat_last,hash_ with hf, andpred_ with pred[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15520)
|
||||
|
||||
*Throws*: Any exception thrown by the copy constructor of RandomAccessIterator1,
|
||||
or by the default constructor, copy constructor, or the copy assignment operator of the value type of RandomAccessIterator1,
|
||||
or the copy constructor or operator() of BinaryPredicate or Hash[.](#4.sentence-1)
|
||||
|
||||
May throw bad_alloc if additional memory needed for internal data structures cannot be allocated[.](#4.sentence-2)
|
||||
|
||||
[ð](#lib:operator(),boyer_moore_horspool_searcher)
|
||||
|
||||
`template<class RandomAccessIterator2>
|
||||
pair<RandomAccessIterator2, RandomAccessIterator2>
|
||||
operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const;
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15536)
|
||||
|
||||
*Mandates*: RandomAccessIterator1 and RandomAccessIterator2 have the same value type[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15541)
|
||||
|
||||
*Effects*: Finds a subsequence of equal values in a sequence[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15545)
|
||||
|
||||
*Returns*: A pair of iterators i and j such that
|
||||
|
||||
- [(7.1)](#7.1)
|
||||
|
||||
i is the first iterator in the range
|
||||
[first, last - (pat_last_ - pat_first_)) such that
|
||||
for every non-negative integer n less than pat_last_ - pat_first_ the following condition holds:pred(*(i + n), *(pat_first_ + n)) != false, and
|
||||
|
||||
- [(7.2)](#7.2)
|
||||
|
||||
j == next(i, distance(pat_first_, pat_last_))[.](#7.sentence-1)
|
||||
|
||||
Returns make_pair(first, first) if [pat_first_, pat_last_) is empty,
|
||||
otherwise returns make_pair(last, last) if no such iterator is found[.](#7.sentence-2)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15559)
|
||||
|
||||
*Complexity*: At most (last - first) * (pat_last_ - pat_first_) applications of the predicate[.](#8.sentence-1)
|
||||
54
cppdraft/func/search/default.md
Normal file
54
cppdraft/func/search/default.md
Normal file
@@ -0,0 +1,54 @@
|
||||
[func.search.default]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.search.default)
|
||||
|
||||
### 22.10.18 Searchers [[func.search]](func.search#default)
|
||||
|
||||
#### 22.10.18.2 Class template default_searcher [func.search.default]
|
||||
|
||||
[ð](#lib:default_searcher)
|
||||
|
||||
namespace std {template<class ForwardIterator1, class BinaryPredicate = equal_to<>>class default_searcher {public:constexpr default_searcher(ForwardIterator1 pat_first, ForwardIterator1 pat_last,
|
||||
BinaryPredicate pred = BinaryPredicate()); template<class ForwardIterator2>constexpr pair<ForwardIterator2, ForwardIterator2>operator()(ForwardIterator2 first, ForwardIterator2 last) const; private: ForwardIterator1 pat_first_; // *exposition only* ForwardIterator1 pat_last_; // *exposition only* BinaryPredicate pred_; // *exposition only*};}
|
||||
|
||||
[ð](#lib:default_searcher,constructor)
|
||||
|
||||
`constexpr default_searcher(ForwardIterator1 pat_first, ForwardIterator1 pat_last,
|
||||
BinaryPredicate pred = BinaryPredicate());
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15331)
|
||||
|
||||
*Effects*: Constructs a default_searcher object, initializing pat_first_ with pat_first, pat_last_ with pat_last, andpred_ with pred[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15338)
|
||||
|
||||
*Throws*: Any exception thrown by the copy constructor of BinaryPredicate orForwardIterator1[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:operator(),default_searcher)
|
||||
|
||||
`template<class ForwardIterator2>
|
||||
constexpr pair<ForwardIterator2, ForwardIterator2>
|
||||
operator()(ForwardIterator2 first, ForwardIterator2 last) const;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15352)
|
||||
|
||||
*Effects*: Returns a pair of iterators i and j such that
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
i == search(first, last, pat_first_, pat_last_, pred_), and
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
if i == last, then j == last,
|
||||
otherwise j == next(i, distance(pat_first_, pat_last_))[.](#3.sentence-1)
|
||||
73
cppdraft/func/search/general.md
Normal file
73
cppdraft/func/search/general.md
Normal file
@@ -0,0 +1,73 @@
|
||||
[func.search.general]
|
||||
|
||||
# 22 General utilities library [[utilities]](./#utilities)
|
||||
|
||||
## 22.10 Function objects [[function.objects]](function.objects#func.search.general)
|
||||
|
||||
### 22.10.18 Searchers [[func.search]](func.search#general)
|
||||
|
||||
#### 22.10.18.1 General [func.search.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15269)
|
||||
|
||||
Subclause [[func.search]](func.search "22.10.18 Searchers") provides function object types ([[function.objects]](function.objects "22.10 Function objects")) for
|
||||
operations that search for a sequence [pat_first, pat_last) in another
|
||||
sequence [first, last) that is provided to the object's function call
|
||||
operator[.](#1.sentence-1)
|
||||
|
||||
The first sequence (the pattern to be searched for) is provided to
|
||||
the object's constructor, and the second (the sequence to be searched) is
|
||||
provided to the function call operator[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15277)
|
||||
|
||||
Each specialization of a class template specified in [[func.search]](func.search "22.10.18 Searchers") shall meet the [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and [*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#2.sentence-1)
|
||||
|
||||
Template parameters named
|
||||
|
||||
- [(2.1)](#2.1)
|
||||
|
||||
ForwardIterator,
|
||||
|
||||
- [(2.2)](#2.2)
|
||||
|
||||
ForwardIterator1,
|
||||
|
||||
- [(2.3)](#2.3)
|
||||
|
||||
ForwardIterator2,
|
||||
|
||||
- [(2.4)](#2.4)
|
||||
|
||||
RandomAccessIterator,
|
||||
|
||||
- [(2.5)](#2.5)
|
||||
|
||||
RandomAccessIterator1,
|
||||
|
||||
- [(2.6)](#2.6)
|
||||
|
||||
RandomAccessIterator2, and
|
||||
|
||||
- [(2.7)](#2.7)
|
||||
|
||||
BinaryPredicate
|
||||
|
||||
of templates specified in[[func.search]](func.search "22.10.18 Searchers") shall meet the same requirements and semantics as
|
||||
specified in [[algorithms.general]](algorithms.general "26.1 General")[.](#2.sentence-2)
|
||||
|
||||
Template parameters named Hash shall meet the [*Cpp17Hash*](hash.requirements#:Cpp17Hash "16.4.4.5 Cpp17Hash requirements [hash.requirements]") requirements (Table [37](hash.requirements#tab:cpp17.hash "Table 37: Cpp17Hash requirements"))[.](#2.sentence-3)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L15296)
|
||||
|
||||
The Boyer-Moore searcher implements the Boyer-Moore search algorithm[.](#3.sentence-1)
|
||||
|
||||
The Boyer-Moore-Horspool searcher implements the Boyer-Moore-Horspool search algorithm[.](#3.sentence-2)
|
||||
|
||||
In general, the Boyer-Moore searcher will use more memory and give better runtime performance than Boyer-Moore-Horspool[.](#3.sentence-3)
|
||||
1768
cppdraft/func/wrap.md
Normal file
1768
cppdraft/func/wrap.md
Normal file
File diff suppressed because it is too large
Load Diff
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