22 General utilities library [utilities]

22.10 Function objects [function.objects]

22.10.15 Function object binders [func.bind]

22.10.15.4 Function template bind [func.bind.bind]

In the text that follows:
  • g is a value of the result of a bind invocation,
  • FD is the type decay_t<F>,
  • fd is an lvalue that is a target object of g ([func.def]) of type FD direct-non-list-initialized with std​::​forward<F>(f),
  • Ti is the ith type in the template parameter pack BoundArgs,
  • TDi is the type decay_t<Ti>,
  • ti is the ith argument in the function parameter pack bound_args,
  • tdi is a bound argument entity of g ([func.def]) of type TDi direct-non-list-initialized with std​::​forward<Ti>(ti),
  • Uj is the jth deduced type of the UnBoundArgs&&... parameter of the argument forwarding call wrapper, and
  • uj is the jth argument associated with Uj.
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);
Mandates: is_constructible_v<FD, F> is true.
For each Ti in BoundArgs, is_constructible_v<TDi, Ti> is true.
Preconditions: FD and each TDi meet the Cpp17MoveConstructible and Cpp17Destructible requirements.
INVOKE(fd, w1, w2, , wN) ([func.require]) is a valid expression for some values w1, w2, , wN, where N has the value sizeof...(bound_args).
Returns: An argument forwarding call wrapper g ([func.require]).
A program that attempts to invoke a volatile-qualified g is ill-formed.
When g is not volatile-qualified, invocation of g(u1, u2, , uM) is expression-equivalent ([defns.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 arguments v1, v2, , vN are determined as specified below.
Throws: Any exception thrown by the initialization of the state entities of g.
[Note 1: 
If all of FD and TDi meet the requirements of Cpp17CopyConstructible, then the return type meets the requirements of Cpp17CopyConstructible.
— end note]
The values of the 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:
  • if TDi is reference_wrapper<T>, the argument is tdi.get() and its type Vi is T&;
  • if the value of is_bind_expression_v<TDi> is true, the argument is static_cast<cv TDi&>(tdi)(std::forward<Uj>(uj)...) and its type Vi is invoke_result_t<cv TDi&, Uj...>&&;
  • 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&&;
  • otherwise, the value is tdi and its type Vi is cv TDi&.
The value of the target argument vfd is fd and its corresponding type Vfd is cv FD&.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.