# std::function::assign

From cppreference.com
< cpp‎ | utility‎ | functional‎ | function

template< class F, class Alloc > void assign( F&& f, const Alloc& alloc ); |  | (since C++11) (until C++17)

Initializes the target with `f`. `alloc` is used to allocate memory for any internal data structures that the `function` might use.

Equivalent to function(allocator_arg, alloc, std::forward<F>(f)).swap(*this)

### Parameters

f | - | callable function to initialize the target with
alloc | - | allocator to use to allocate memory for the internal data structures

### Return value

(none)

### Exceptions

(none)

### See also

operator= | assigns a new target (public member function)

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/utility/functional/function/assign&oldid=81480"