22 General utilities library [utilities] (original) (raw)

22.10 Function objects [function.objects]

22.10.15 Function object binders [func.bind]


22.10.15.1 General [func.bind.general]

22.10.15.2 Class template is_bind_expression [func.bind.isbind]

22.10.15.3 Class template is_placeholder [func.bind.isplace]

22.10.15.4 Function template bind [func.bind.bind]

22.10.15.5 Placeholders [func.bind.place]


22.10.15.1 General [func.bind.general]

Subclause [func.bind] describes a uniform mechanism for binding arguments of callable objects.

22.10.15.2 Class template is_bind_expression [func.bind.isbind]

namespace std { template<class T> struct is_bind_expression; }

The class template is_bind_expression can be used to detect function objects generated by bind.

The function template binduses is_bind_expression to detect subexpressions.

The implementation provides a definition that has a base characteristic oftrue_type if T is a type returned from bind, otherwise it has a base characteristic of false_type.

A program may specialize this template for a program-defined type Tto have a base characteristic of true_type to indicate thatT should be treated as a subexpression in a bind call.

22.10.15.3 Class template is_placeholder [func.bind.isplace]

namespace std { template<class T> struct is_placeholder; }

The class template is_placeholder can be used to detect the standard placeholders_1, _2, and so on ([func.bind.place]).

The function template bind usesis_placeholder to detect placeholders.

The implementation provides a definition that has the base characteristic ofintegral_constant<int, _J_> if T is the type ofstd​::​placeholders​::​_ J, otherwise it has a base characteristic of integral_constant<int, 0>.

A program may specialize this template for a program-defined type T to have a base characteristic of integral_constant<int, N>with N > 0 to indicate that T should be treated as a placeholder type.

22.10.15.4 Function template bind [func.bind.bind]

In the text that follows:

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.

INVOKE(fd, , , …,) ([func.require]) is a valid expression for some values , , …, , whereN has the value sizeof...(bound_args).

Returns: An argument forwarding call wrapper g ([func.require]).

A program that attempts to invoke a volatile-qualified gis ill-formed.

When g is not volatile-qualified, invocation ofg(, , …, )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.

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:

The value of the target argument is fd and its corresponding type is cv FD&.

22.10.15.5 Placeholders [func.bind.place]

namespace std::placeholders { see below _1;see below _2; ⋮see below _ M;}

The number M of placeholders isimplementation-defined.

All placeholder types meet the Cpp17DefaultConstructible andCpp17CopyConstructible requirements, and their default constructors and copy/move constructors are constexpr functions that do not throw exceptions.

It is implementation-defined whether placeholder types meet the Cpp17CopyAssignable requirements, but if so, their copy assignment operators are constexpr functions that do not throw exceptions.

Placeholders should be defined as:inline constexpr unspecified _1{};

If they are not, they are declared as:extern unspecified _1;