23 General utilities library [utilities]

23.14 Function objects [function.objects]

23.14.11 Function object binders [func.bind]

23.14.11.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),
  • T is the type in the template parameter pack BoundArgs,
  • TD is the type decay_­t<T>,
  • t is the argument in the function parameter pack bound_­args,
  • td is an lvalue of type TD constructed from std​::​forward<T>(t),
  • U is the deduced type of the UnBoundArgs&&... parameter of the forwarding call wrapper, and
  • u is the argument associated with U.
template<class F, class... BoundArgs> unspecified bind(F&& f, BoundArgs&&... bound_args);
Requires: is_­constructible_­v<FD, F> shall be true.
For each T in BoundArgs, is_­constructible_­v<TD, T> shall be true.
INVOKE(fd, w, w, …, w) ([func.require]) shall be a valid expression for some values w, w, …, w, 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: A forwarding call wrapper g ([func.require]).
The effect of g(u, u, …, u) shall be
INVOKE(fd, std::forward<V>(v), std::forward<V>(v), …, std::forward<V>(v))
where the values and types of the bound arguments v, v, …, v are determined as specified below.
The copy constructor and move constructor of the forwarding call wrapper shall throw an exception if and only if the corresponding constructor of FD or of any of the types TD throws an exception.
Throws: Nothing unless the construction of fd or of one of the values td throws an exception.
Remarks: The return type shall satisfy the requirements of MoveConstructible.
If all of FD and TD satisfy the requirements of CopyConstructible, then the return type shall satisfy the requirements of CopyConstructible.
[ Note
:
This implies that all of FD and TD are MoveConstructible.
— 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 T in BoundArgs, is_­constructible_­v<TD, T> shall be true.
INVOKE(fd, w, w, …, w) shall be a valid expression for some values w, w, …, w, 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: A forwarding call wrapper g ([func.require]).
The effect of g(u, u, …, u) shall be
INVOKE<R>(fd, std::forward<V>(v), std::forward<V>(v), …, std::forward<V>(v))
where the values and types of the bound arguments v, v, …, v are determined as specified below.
The copy constructor and move constructor of the forwarding call wrapper shall throw an exception if and only if the corresponding constructor of FD or of any of the types TD throws an exception.
Throws: Nothing unless the construction of fd or of one of the values td throws an exception.
Remarks: The return type shall satisfy the requirements of MoveConstructible.
If all of FD and TD satisfy the requirements of CopyConstructible, then the return type shall satisfy the requirements of CopyConstructible.
[ Note
:
This implies that all of FD and TD are MoveConstructible.
— end note
 ]
The values of the bound arguments v, v, …, v and their corresponding types V, V, …, V depend on the types TD derived from the call to bind and the cv-qualifiers cv of the call wrapper g as follows:
  • if TD is reference_­wrapper<T>, the argument is td.get() and its type V is T&;
  • if the value of is_­bind_­expression_­v<TD> is true, the argument is td(std​::​forward<U>(u)...) and its type V is invoke_­result_­t<TD cv &, U...>&&;
  • if the value j of is_­placeholder_­v<TD> is not zero, the argument is std​::​forward<U>(u) and its type V is U&&;
  • otherwise, the value is td and its type V is TD cv &.