22 General utilities library [utilities] (original) (raw)
22.10 Function objects [function.objects]
22.10.4 Requirements [func.require]
Define INVOKE(f, t, t, …, t) as follows:
- (t.*f)(t, …, t) when f is a pointer to a member function of a class Tandis_same_v<T, remove_cvref_t<decltype(t)>> || is_base_of_v<T, remove_cvref_t<decltype(t)>> is true;
- (t.get().*f)(t, …, t) when f is a pointer to a member function of a class Tand remove_cvref_t<decltype(t)> is a specialization of reference_wrapper;
- ((*t).*f)(t, …, t) when f is a pointer to a member function of a class Tand t does not satisfy the previous two items;
- t.*f when and f is a pointer to data member of a class Tandis_same_v<T, remove_cvref_t<decltype(t)>> || is_base_of_v<T, remove_cvref_t<decltype(t)>> is true;
- t.get().*f when and f is a pointer to data member of a class Tand remove_cvref_t<decltype(t)> is a specialization of reference_wrapper;
- (*t).*f when and f is a pointer to data member of a class Tand t does not satisfy the previous two items;
- f(t, t, …, t) in all other cases.
Define INVOKE<R>(f, t, t, …, t) asstatic_cast<void>(INVOKE(f, t, t, …, t))if R is cv void, otherwise_INVOKE_(f, t, t, …, t) implicitly converted to R.
Ifreference_converts_from_temporary_v<R, decltype(_INVOKE_(f, t, t, …, t))>is true,INVOKE<R>(f, t, t, …, t)is ill-formed.
An argument forwarding call wrapper is a call wrapper that can be called with an arbitrary argument list and delivers the arguments to the target object as references.
This forwarding step delivers rvalue arguments as rvalue references and lvalue arguments as lvalue references.
[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_]
A perfect forwarding call wrapper is an argument forwarding call wrapper that forwards its state entities to the underlying call expression.
This forwarding step delivers a state entity of type Tas 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.
A call pattern defines the semantics of invoking a perfect forwarding call wrapper.
A postfix call performed on a perfect forwarding call wrapper is expression-equivalent ([defns.expression.equivalent]) to an expression e determined from its call pattern cpby replacing all occurrences of the arguments of the call wrapper and its state entities with references as described in the corresponding forwarding steps.
A simple call wrapper is a perfect forwarding call wrapper that meets the Cpp17CopyConstructible and Cpp17CopyAssignable requirements and whose copy constructor, move constructor, and assignment operators are constexpr functions that do not throw exceptions.
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]).
[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 constexprif the corresponding implicit definition would be considered to be constexpr.
— _end note_]
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.