[func.bind.bind]

# 22 General utilities library [[utilities]](./#utilities)

## 22.10 Function objects [[function.objects]](function.objects#func.bind.bind)

### 22.10.15 Function object binders [[func.bind]](func.bind#bind)

#### 22.10.15.4 Function template bind [func.bind.bind]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13401)

In the text that follows:

- [(1.1)](#1.1)

g is a value of the result of a bind invocation,

- [(1.2)](#1.2)

FD is the type decay_t<F>,

- [(1.3)](#1.3)

fd is an lvalue that
 is a target object of g ([[func.def]](func.def "22.10.3 Definitions")) of type FD direct-non-list-initialized with std​::​forward<F>(f),

- [(1.4)](#1.4)

Ti is the ith type in the template parameter pack BoundArgs,

- [(1.5)](#1.5)

TDi is the type decay_t<Ti>,

- [(1.6)](#1.6)

ti is the ith argument in the function parameter pack bound_args,

- [(1.7)](#1.7)

tdi is a bound argument entity
 of g ([[func.def]](func.def "22.10.3 Definitions")) of type TDi direct-non-list-initialized with std​::​forward<​Ti>(ti),

- [(1.8)](#1.8)

Uj is the jth deduced type of the UnBoundArgs&&... parameter
 of the argument forwarding call wrapper, and

- [(1.9)](#1.9)

uj is the jth argument associated with Uj[.](#1.sentence-1)

[ð](#lib:bind_)

`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);
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13430)

*Mandates*: is_constructible_v<FD, F> is true[.](#2.sentence-1)

For each Ti in BoundArgs, is_constructible_v<TDi, Ti> is true[.](#2.sentence-2)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13435)

*Preconditions*: FD and each TDi meet
the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") and [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#3.sentence-1)

*INVOKE*(fd, w1, w2, …,wN) ([[func.require]](func.require "22.10.4 Requirements")) is a valid expression for some
values w1, w2, …, wN, whereN has the value sizeof...(bound_args)[.](#3.sentence-2)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13444)

*Returns*: An argument forwarding call wrapper g ([[func.require]](func.require "22.10.4 Requirements"))[.](#4.sentence-1)

A program that attempts to invoke a volatile-qualified g is ill-formed[.](#4.sentence-2)

When g is not volatile-qualified, invocation ofg(u1, u2, …, uM) is expression-equivalent ([[defns.expression.equivalent]](defns.expression.equivalent "3.22 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 argumentsv1, v2, …, vN are determined as specified below[.](#4.sentence-3)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13466)

*Throws*: Any exception thrown by the initialization of
the state entities of g[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13471)

[*Note [1](#note-1)*:

If all of FD and TDi meet
the requirements of [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]"), then
the return type meets the requirements of [*Cpp17CopyConstructible*](utility.arg.requirements#:Cpp17CopyConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]")[.](#6.sentence-1)

â *end note*]

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13479)

The values of the [*bound arguments*](#def: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:

- [(7.1)](#7.1)

if TDi is reference_wrapper<T>, the
argument is tdi.get() and its type Vi is T&;

- [(7.2)](#7.2)

if the value of is_bind_expression_v<TDi> is true, the argument isstatic_cast<cv TDi&>(tdi)(std::forward<Uj>(uj)...) and its type Vi isinvoke_result_t<cv TDi&, Uj...>&&;

- [(7.3)](#7.3)

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&&;

- [(7.4)](#7.4)

otherwise, the value is tdi and its type Vi is cv TDi&[.](#7.sentence-1)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/utilities.tex#L13507)

The value of the target argument vfd is fd and
its corresponding type Vfd is cv FD&[.](#8.sentence-1)
