[func.wrap.func.general]

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

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

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

#### 22.10.17.3 Class template function [[func.wrap.func]](func.wrap.func#general)

#### 22.10.17.3.1 General [func.wrap.func.general]

[ð](#lib:result_type,function)

namespace std {template<class R, class... ArgTypes>class function<R(ArgTypes...)> {public:using result_type = R; // [[func.wrap.func.con]](func.wrap.func.con "22.10.17.3.2 Constructors and destructor"), construct/copy/destroy function() noexcept;
 function(nullptr_t) noexcept;
 function(const function&);
 function(function&&) noexcept; template<class F> function(F&&);

 function& operator=(const function&);
 function& operator=(function&&);
 function& operator=(nullptr_t) noexcept; template<class F> function& operator=(F&&); template<class F> function& operator=(reference_wrapper<F>) noexcept; ~function(); // [[func.wrap.func.mod]](func.wrap.func.mod "22.10.17.3.3 Modifiers"), function modifiersvoid swap(function&) noexcept; // [[func.wrap.func.cap]](func.wrap.func.cap "22.10.17.3.4 Capacity"), function capacityexplicit operator bool() const noexcept; // [[func.wrap.func.inv]](func.wrap.func.inv "22.10.17.3.5 Invocation"), function invocation R operator()(ArgTypes...) const; // [[func.wrap.func.targ]](func.wrap.func.targ "22.10.17.3.6 Target access"), function target accessconst type_info& target_type() const noexcept; template<class T> T* target() noexcept; template<class T> const T* target() const noexcept; }; template<class R, class... ArgTypes> function(R(*)(ArgTypes...)) -> function<R(ArgTypes...)>; template<class F> function(F) -> function<*see below*>;}

[1](#1)

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

The function class template provides polymorphic wrappers that
generalize the notion of a function pointer[.](#1.sentence-1)

Wrappers can store, copy,
and call arbitrary callable objects ([[func.def]](func.def "22.10.3 Definitions")), given a call
signature ([[func.def]](func.def "22.10.3 Definitions"))[.](#1.sentence-2)

[2](#2)

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

The function class template is a call
wrapper ([[func.def]](func.def "22.10.3 Definitions")) whose call signature ([[func.def]](func.def "22.10.3 Definitions"))
is R(ArgTypes...)[.](#2.sentence-1)

[3](#3)

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

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

The types deduced by the deduction guides for function might change in future revisions of C++[.](#3.sentence-1)

â *end note*]
