[func.wrap.move.class]

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

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

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

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

#### 22.10.17.4.2 Class template move_only_function [func.wrap.move.class]

[ð](#lib:move_only_function)

namespace std {template<class R, class... ArgTypes>class move_only_function<R(ArgTypes...) cv *ref* noexcept(*noex*)> {public:using result_type = R; // [[func.wrap.move.ctor]](func.wrap.move.ctor "22.10.17.4.3 Constructors, assignments, and destructor"), constructors, assignments, and destructor move_only_function() noexcept;
 move_only_function(nullptr_t) noexcept;
 move_only_function(move_only_function&&) noexcept; template<class F> move_only_function(F&&); template<class T, class... Args>explicit move_only_function(in_place_type_t<T>, Args&&...); template<class T, class U, class... Args>explicit move_only_function(in_place_type_t<T>, initializer_list<U>, Args&&...);

 move_only_function& operator=(move_only_function&&);
 move_only_function& operator=(nullptr_t) noexcept; template<class F> move_only_function& operator=(F&&); ~move_only_function(); // [[func.wrap.move.inv]](func.wrap.move.inv "22.10.17.4.4 Invocation"), invocationexplicit operator bool() const noexcept;
 R operator()(ArgTypes...) cv *ref* noexcept(*noex*); // [[func.wrap.move.util]](func.wrap.move.util "22.10.17.4.5 Utility"), utilityvoid swap(move_only_function&) noexcept; friend void swap(move_only_function&, move_only_function&) noexcept; friend bool operator==(const move_only_function&, nullptr_t) noexcept; private:template<class VT>static constexpr bool *is-callable-from* = *see below*; // *exposition only*};}

[1](#1)

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

The move_only_function class template provides polymorphic wrappers
that generalize the notion of a callable object ([[func.def]](func.def "22.10.3 Definitions"))[.](#1.sentence-1)

These wrappers can store, move, and call arbitrary callable objects,
given a call signature[.](#1.sentence-2)

[2](#2)

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

*Recommended practice*: Implementations should avoid the use of dynamically allocated memory
for a small contained value[.](#2.sentence-1)

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

Such small-object optimization can only be applied to a type T for which is_nothrow_move_constructible_v<T> is true[.](#2.sentence-2)

â *end note*]
