This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

145
cppdraft/func/bind/bind.md Normal file
View 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.3Definitions")) 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.3Definitions")) 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.2Template argument requirements[utility.arg.requirements]") and [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2Template argument requirements[utility.arg.requirements]") requirements[.](#3.sentence-1)
*INVOKE*(fd, w1, w2, …,wN) ([[func.require]](func.require "22.10.4Requirements")) 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.4Requirements"))[.](#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.22expression-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.2Template argument requirements[utility.arg.requirements]"), then
the return type meets the requirements of [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template 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)

View 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.15Function object binders") describes a uniform mechanism for binding
arguments of callable objects[.](#1.sentence-1)

View 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.2Requirements[meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2Requirements"))[.](#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)

View 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.5Placeholders"))[.](#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.2Requirements[meta.rqmts]") requirements ([[meta.rqmts]](meta.rqmts "21.3.2Requirements"))[.](#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)

View 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.3Definitions"))
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.3Definitions"))
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.3Function 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.2Template 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.2Template 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.4Requirements")) 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.3Definitions"))[.](#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.3Definitions")) 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.3Function 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.2Template 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.4Requirements")) 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)

View 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.2Template argument requirements[utility.arg.requirements]") and[*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template 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.2Template 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.7Freestanding items"))[.](#4.sentence-1)