cpp/utility/functional/function/function

Constructs a from a variety of sources.

@1-2@ Creates an empty function.

@3-4@ Copies or moves  the target of  to the target of. If is empty,  will be empty after the call too. For, is in a valid but unspecified state after the call.

@5@ Initializes the target with. The target is of type. If is a null pointer to function, a null pointer to member, or an empty value of some  specialization,  will be empty after the call. This constructor does not participate in overload resolution unless the target type is not same as, and its lvalue is for argument types  and return type. The program is ill-formed if the target type is not copy-constructible or initialization of the target is ill-formed.

@6-10@ Same as except that  is used to allocate memory for any internal data structures that the  might use.

When the target is a function pointer or a std, small object optimization is guaranteed, that is, these targets are always directly stored inside the std object, no dynamic allocation takes place. Other large objects may be constructed in dynamic allocated storage and accessed by the std object through a pointer.

Exceptions
@3,8,9@ Does not throw if 's target is a function pointer or a std, otherwise may throw std or any exception thrown by the constructor used to copy or move the stored callable object.

@5,10@ Does not throw if is a function pointer or a std, otherwise may throw std or any exception thrown by the copy constructor of the stored callable object.