A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/functional/function/assign/ below:

public member function

<functional>

std::function::assign
template <class Fn, class Alloc>  void assign (Fn&& fn, const Alloc& alloc);

Assign target and allocator

Assigns a new value to the function object, replacing its current target and setting alloc as the internal allocator.

The function behaves as if a new function was constructed on the stack by forwarding fn and alloc to the proper constructor, and swapping that newly constructed object with *this:


1
function(allocator_arg,alloc,std::forward<Fn>(fn)).swap(*this)

Parameters
fn
Either a function object of the same type, or some function, function pointer, pointer to member, or function object, as forwarded to function's constructor.

Return value none

Data races The object is modified (including both its target and its allocator).
If fn is an rvalue reference, the function may modify fn.

Exception safety If fn is a function pointer or a reference_wrapper to a callable object (or a function object targeting one of these), it never throws exceptions (no-throw guarantee).
Otherwise, it can only throw if the copy- or move-construction of the target callable object throws, or if an exception (such as bad_alloc) is thrown allocating memory.

See also
function::operator=
Assign function object (public member function)
function::function
Construct function wrapper (public member function)
swap (function)
Exchanges the targets (public member function)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4