Create a function wrapping func using the specified allocator.

Synopsis

Declared in <bslstl_function.h>

template<class FUNC>
function(
    std::allocator_arg_t allocatorArg,
    allocator_type const& allocator,
    FUNC&& func)
requires ! IsReferenceCompatible<typename Decay<FUNC>::type,
                                            function>::value
                 &&   IsInvocableWithPrototype<
                                             typename Decay<FUNC>::type>::value;

Description

Create an object wrapping the specified func callable object. Use the specified allocator (i.e., the address of a bslma::Allocator object) to supply memory. If func is a null pointer or null pointer‐to‐member, then the resulting object will be empty. This constructor will not participate in overload resolution if func is of the same type as (or reference compatible with) this object (to avoid ambiguity with the extended copy and move constructors) or is an integral type (to avoid matching null pointer literals). In C++03, this function will not participate in overload resolution if FUNC is a MovableRef (see overload, below), and instantiation will fail unless FUNC is invocable using the arguments and return type specified in PROTOTYPE. In C++11 and later, this function will not participate in overload resolution if FUNC is not invocable using the arguments and return type specified in PROTOTYPE. Note that this constructor implicitly converts from any type that is so invocable.

Parameters

Name

Description

allocatorArg

allocator‐argument tag (unused)

allocator

allocator used to supply memory

func

callable object to wrap as the target

Created with MrDocs