[#bsl-function-0a-2constructor-0e]
= xref:bsl.adoc[bsl]::xref:bsl/function-0a.adoc[function]::function
:relfileprefix: ../../
:mrdocs:

Create an object wrapping the specified `func` callable object&period; Use the specified `allocator` (i&period;e&period;, the address of a `bslma&colon;&colon;Allocator` object) to supply memory&period; If `func` is a null pointer or null pointer&hyphen;to&hyphen;member, then the resulting object will be empty&period; 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)&period; In C&plus;&plus;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`&period; In C&plus;&plus;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`&period; Note that this constructor implicitly converts from any type that is so invocable&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;function&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class FUNC&gt;
function(
    std::allocator&lowbar;arg&lowbar;t,
    xref:bsl/function-0a/allocator_type.adoc[allocator&lowbar;type] const& allocator,
    FUNC&& func)
requires ! IsReferenceCompatible&lt;typename Decay&lt;FUNC&gt;&colon;&colon;type,
                                            function&gt;&colon;&colon;value
                 &amp;&amp;   IsInvocableWithPrototype&lt;
                                             typename Decay&lt;FUNC&gt;&colon;&colon;type&gt;&colon;&colon;value;
----


[.small]#Created with https://www.mrdocs.com[MrDocs]#
