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:
  • FD is the type decay_­t<F>,
  • fd is an lvalue of type FD constructed from 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 an lvalue of type constructed from 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> unspecified bind(F&& f, BoundArgs&&... bound_args);
Requires: is_­constructible_­v<FD, F> shall be true.
For each in BoundArgs, is_­constructible_­v<, > shall be true.
INVOKE(fd, , , , ) ([func.require]) shall be a valid expression for some values , , , , where N has the value sizeof...(bound_­args).
The cv-qualifiers cv of the call wrapper g, as specified below, shall be neither volatile nor const volatile.
Returns: An argument forwarding call wrapper g ([func.require]).
The effect of g(, , , ) is
INVOKE(fd, std::forward<>(), std::forward<>(), , std::forward<>())
where the values and types of the bound arguments , , , are determined as specified below.
The copy constructor and move constructor of the argument forwarding call wrapper throw an exception if and only if the corresponding constructor of FD or of any of the types throws an exception.
Throws: Nothing unless the construction of fd or of one of the values throws an exception.
Remarks: The return type meets the Cpp17MoveConstructible requirements.
If all of FD and meet the Cpp17CopyConstructible requirements, then the return type meets the Cpp17CopyConstructible requirements.
[Note
:
This implies that all of FD and are Cpp17MoveConstructible.
end note
]
template<class R, class F, class... BoundArgs> unspecified bind(F&& f, BoundArgs&&... bound_args);
Requires: is_­constructible_­v<FD, F> shall be true.
For each in BoundArgs, is_­constructible_­v<, > shall be true.
INVOKE(fd, , , , ) shall be a valid expression for some values , , , , where N has the value sizeof...(bound_­args).
The cv-qualifiers cv of the call wrapper g, as specified below, shall be neither volatile nor const volatile.
Returns: An argument forwarding call wrapper g ([func.require]).
The effect of g(, , , ) is
INVOKE<R>(fd, std::forward<>(), std::forward<>(), , std::forward<>())
where the values and types of the bound arguments , , , are determined as specified below.
The copy constructor and move constructor of the argument forwarding call wrapper throw an exception if and only if the corresponding constructor of FD or of any of the types throws an exception.
Throws: Nothing unless the construction of fd or of one of the values throws an exception.
Remarks: The return type meets the Cpp17MoveConstructible requirements.
If all of FD and meet the Cpp17CopyConstructible requirements, then the return type meets the Cpp17CopyConstructible requirements.
[Note
:
This implies that all of FD and are Cpp17MoveConstructible.
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 (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 &.