20 General utilities library [utilities]

20.14 Function objects [function.objects]

20.14.14 Function object binders [func.bind]

20.14.14.3 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),
  • is the type in the template parameter pack BoundArgs,
  • is the type decay_­t<>,
  • is the argument in the function parameter pack bound_­args,
  • is a bound argument entity of g ([func.def]) of type direct-non-list-initialized with std​::​forward<>(),
  • is the deduced type of the UnBoundArgs&&... parameter of the argument forwarding call wrapper, and
  • is the argument associated with .
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 in BoundArgs, is_­constructible_­v<, > is true.
Preconditions: FD and each meet the Cpp17MoveConstructible and Cpp17Destructible requirements.
INVOKE(fd, , , , ) ([func.require]) is a valid expression for some values , , , , 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(, , , ) is expression-equivalent ([defns.expression-equivalent]) to
INVOKE(static_cast<>(),
       static_cast<>(), static_cast<>(), , static_cast<>())
for the first overload, and
INVOKE<R>(static_cast<>(),
          static_cast<>(), static_cast<>(), , static_cast<>())
for the second overload, where the values and types of the target argument and of the bound arguments , , , are determined as specified below.
Throws: Any exception thrown by the initialization of the state entities of g.
[Note
:
If all of FD and meet the requirements of Cpp17CopyConstructible, then the return type meets the requirements of Cpp17CopyConstructible.
— end note
]
The values of the bound arguments , , , and their corresponding types , , , depend on the types derived from the call to bind and the cv-qualifiers cv of the call wrapper g as follows:
  • if is reference_­wrapper<T>, the argument is .get() and its type is T&;
  • if the value of is_­bind_­expression_­v<> is true, the argument is
    static_cast<cv &>()(std::forward<>()...)
    
    and its type is invoke_­result_­t<cv &, ...>&&;
  • if the value j of is_­placeholder_­v<> is not zero, the argument is std​::​forward<>() and its type is &&;
  • otherwise, the value is and its type is cv &.
The value of the target argument is fd and its corresponding type is cv FD&.