[func.wrap.move.ctor]

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

## 22.10 Function objects [[function.objects]](function.objects#func.wrap.move.ctor)

### 22.10.17 Polymorphic function wrappers [[func.wrap]](func.wrap#move.ctor)

#### 22.10.17.4 Move-only wrapper [[func.wrap.move]](func.wrap.move#ctor)

#### 22.10.17.4.3 Constructors, assignments, and destructor [func.wrap.move.ctor]

[ð](#:move_only_function::is-callable-from)

`template<class VT>
  static constexpr bool is-callable-from = see below;
`

[1](#1)

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

If *noex* is true,*is-callable-from*<VT> is equal to:is_nothrow_invocable_r_v<R, VT cv *ref*, ArgTypes...> && is_nothrow_invocable_r_v<R, VT *inv-quals*, ArgTypes...>

Otherwise, *is-callable-from*<VT> is equal to:is_invocable_r_v<R, VT cv *ref*, ArgTypes...> && is_invocable_r_v<R, VT *inv-quals*, ArgTypes...>

[ð](#lib:move_only_function,constructor)

`move_only_function() noexcept;
move_only_function(nullptr_t) noexcept;
`

[2](#2)

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

*Postconditions*: *this has no target object[.](#2.sentence-1)

[ð](#lib:move_only_function,constructor_)

`move_only_function(move_only_function&& f) noexcept;
`

[3](#3)

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

*Postconditions*: The target object of *this is
the target object f had before construction, andf is in a valid state with an unspecified value[.](#3.sentence-1)

[ð](#lib:move_only_function,constructor__)

`template<class F> move_only_function(F&& f);
`

[4](#4)

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

Let VT be decay_t<F>[.](#4.sentence-1)

[5](#5)

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

*Constraints*: 

- [(5.1)](#5.1)

remove_cvref_t<F> is not the same type as move_only_function, and

- [(5.2)](#5.2)

remove_cvref_t<F> is not a specialization of in_place_type_t, and

- [(5.3)](#5.3)

*is-callable-from*<VT> is true[.](#5.sentence-1)

[6](#6)

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

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

[7](#7)

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

*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements, and
if is_move_constructible_v<VT> is true,VT meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#7.sentence-1)

[8](#8)

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

*Postconditions*: *this has no target object if any of the following hold:

- [(8.1)](#8.1)

f is a null function pointer value, or

- [(8.2)](#8.2)

f is a null member pointer value, or

- [(8.3)](#8.3)

remove_cvref_t<F> is a specialization of
the move_only_function class template,
and f has no target object[.](#8.sentence-1)

Otherwise, *this has a target object of type VT direct-non-list-initialized with std​::​forward<F>(f)[.](#8.sentence-2)

[9](#9)

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

*Throws*: Any exception thrown by the initialization of the target object[.](#9.sentence-1)

May throw bad_alloc unless VT is
a function pointer or a specialization of reference_wrapper[.](#9.sentence-2)

[ð](#lib:move_only_function,constructor___)

`template<class T, class... Args>
  explicit move_only_function(in_place_type_t<T>, Args&&... args);
`

[10](#10)

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

Let VT be decay_t<T>[.](#10.sentence-1)

[11](#11)

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

*Constraints*: 

- [(11.1)](#11.1)

is_constructible_v<VT, Args...> is true, and

- [(11.2)](#11.2)

*is-callable-from*<VT> is true[.](#11.sentence-1)

[12](#12)

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

*Mandates*: VT is the same type as T[.](#12.sentence-1)

[13](#13)

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

*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements, and
if is_move_constructible_v<VT> is true,VT meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#13.sentence-1)

[14](#14)

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

*Postconditions*: *this has a target object of type VT direct-non-list-initialized with std​::​forward<Args>​(args)...[.](#14.sentence-1)

[15](#15)

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

*Throws*: Any exception thrown by the initialization of the target object[.](#15.sentence-1)

May throw bad_alloc unless VT is
a function pointer or a specialization of reference_wrapper[.](#15.sentence-2)

[ð](#lib:move_only_function,constructor____)

`template<class T, class U, class... Args>
  explicit move_only_function(in_place_type_t<T>, initializer_list<U> ilist, Args&&... args);
`

[16](#16)

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

Let VT be decay_t<T>[.](#16.sentence-1)

[17](#17)

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

*Constraints*: 

- [(17.1)](#17.1)

is_constructible_v<VT, initializer_list<U>&, Args...> istrue, and

- [(17.2)](#17.2)

*is-callable-from*<VT> is true[.](#17.sentence-1)

[18](#18)

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

*Mandates*: VT is the same type as T[.](#18.sentence-1)

[19](#19)

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

*Preconditions*: VT meets the [*Cpp17Destructible*](utility.arg.requirements#:Cpp17Destructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements, and
if is_move_constructible_v<VT> is true,VT meets the [*Cpp17MoveConstructible*](utility.arg.requirements#:Cpp17MoveConstructible "16.4.4.2 Template argument requirements [utility.arg.requirements]") requirements[.](#19.sentence-1)

[20](#20)

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

*Postconditions*: *this has a target object of type VT direct-non-list-initialized withilist, std​::​forward<Args>(args)...[.](#20.sentence-1)

[21](#21)

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

*Throws*: Any exception thrown by the initialization of the target object[.](#21.sentence-1)

May throw bad_alloc unless VT is
a function pointer or a specialization of reference_wrapper[.](#21.sentence-2)

[ð](#lib:operator=,move_only_function)

`move_only_function& operator=(move_only_function&& f);
`

[22](#22)

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

*Effects*: Equivalent to: move_only_function(std​::​move(f)).swap(*this);

[23](#23)

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

*Returns*: *this[.](#23.sentence-1)

[ð](#lib:operator=,move_only_function_)

`move_only_function& operator=(nullptr_t) noexcept;
`

[24](#24)

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

*Effects*: Destroys the target object of *this, if any[.](#24.sentence-1)

[25](#25)

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

*Returns*: *this[.](#25.sentence-1)

[ð](#lib:operator=,move_only_function__)

`template<class F> move_only_function& operator=(F&& f);
`

[26](#26)

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

*Effects*: Equivalent to: move_only_function(std​::​forward<F>(f)).swap(*this);

[27](#27)

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

*Returns*: *this[.](#27.sentence-1)

[ð](#lib:move_only_function,destructor)

`~move_only_function();
`

[28](#28)

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

*Effects*: Destroys the target object of *this, if any[.](#28.sentence-1)
