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

136
cppdraft/func/require.md Normal file
View 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.3Definitions")) meets 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)
An [*argument forwarding call wrapper*](#def:argument_forwarding_call_wrapper "22.10.4Requirements[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.4Requirements[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.4Requirements[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.22expression-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.4Requirements[func.require]") is a perfect forwarding call wrapper that meets
the [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2Template argument requirements[utility.arg.requirements]") and [*Cpp17CopyAssignable*](utility.arg.requirements#:Cpp17CopyAssignable "16.4.4.2Template 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.3Copy/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)