[#bsl-function-0a-2constructor-075] = xref:bsl.adoc[bsl]::xref:bsl/function-0a.adoc[function]::function :relfileprefix: ../../ :mrdocs: Constructors == Synopses Declared in `<bslstl_function.h>` Create an empty `function` that does not target any callable. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a/2constructor-0a.adoc[function]() noexcept; ---- [.small]#xref:bsl/function-0a/2constructor-0a.adoc[_» more..._]# Create a `function` having the same value as (i.e., wrapping a copy of the target held by) the specified `original` object. Optionally specify an `allocator` (e.g., the address of a `bslma::Allocator` object) to supply memory; otherwise, the default allocator is used. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a/2constructor-070.adoc[function](xref:bsl/function-0a.adoc[function] const& original); ---- [.small]#xref:bsl/function-0a/2constructor-070.adoc[_» more..._]# Create an empty `function` that does not target any callable. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a/2constructor-0b.adoc[function](xref:bsl/nullptr_t-08.adoc[nullptr_t]) noexcept; ---- [.small]#xref:bsl/function-0a/2constructor-0b.adoc[_» more..._]# Create a `function` having the same target as the specified `original` object. Use `original.get_allocator()` as the allocator to supply memory. The `original` object is set to empty after the new object is created. If the target qualifies for the small‐object optimization (see class‐level documentation), then it is move‐constructed into the new object; otherwise ownership of the target is transferred without using the target's move constructor. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a/2constructor-074.adoc[function](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<function>] original) noexcept; ---- [.small]#xref:bsl/function-0a/2constructor-074.adoc[_» more..._]# Create an object wrapping the specified `func` callable object. Use the default allocator 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 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class FUNC> xref:bsl/function-0a/2constructor-03f.adoc[function](FUNC&& func) requires ! IsReferenceCompatible<typename Decay<FUNC>::type, function>::value && IsInvocableWithPrototype< typename Decay<FUNC>::type>::value; ---- [.small]#xref:bsl/function-0a/2constructor-03f.adoc[_» more..._]# Create an empty `function` object using the specified `allocator` (e.g., the address of a `bslma::Allocator` object) to supply memory. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a/2constructor-03b1.adoc[function]( std::allocator_arg_t, xref:bsl/function-0a/allocator_type.adoc[allocator_type] const& allocator) noexcept; ---- [.small]#xref:bsl/function-0a/2constructor-03b1.adoc[_» more..._]# Create an empty `function` object. Optionally specify an `allocator` (e.g., the address of a `bslma::Allocator` object) to supply memory; otherwise, the default allocator is used. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a/2constructor-02.adoc[function]( std::allocator_arg_t, xref:bsl/function-0a/allocator_type.adoc[allocator_type] const& allocator, xref:bsl/nullptr_t-08.adoc[nullptr_t]) noexcept; ---- [.small]#xref:bsl/function-0a/2constructor-02.adoc[_» more..._]# Create a `function` having the same value as (i.e., wrapping a copy of the target held by) the specified `original` object. Use the specified `allocator` (e.g., the address of a `bslma::Allocator` object) to supply memory. If `allocator == original.allocator()`, this object is created as if by move construction; otherwise it is created as if by extended copy construction using `allocator`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a/2constructor-03bb.adoc[function]( std::allocator_arg_t, xref:bsl/function-0a/allocator_type.adoc[allocator_type] const& allocator, xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<function>] original); ---- [.small]#xref:bsl/function-0a/2constructor-03bb.adoc[_» more..._]# Create a `function` having the same value as the specified `original` object, using the specified `allocator` to supply memory. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/function-0a/2constructor-0d.adoc[function]( std::allocator_arg_t, xref:bsl/function-0a/allocator_type.adoc[allocator_type] const& allocator, xref:bsl/function-0a.adoc[function] const& original); ---- [.small]#xref:bsl/function-0a/2constructor-0d.adoc[_» more..._]# 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. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class FUNC> xref:bsl/function-0a/2constructor-0e.adoc[function]( std::allocator_arg_t, xref:bsl/function-0a/allocator_type.adoc[allocator_type] const& allocator, FUNC&& func) requires ! IsReferenceCompatible<typename Decay<FUNC>::type, function>::value && IsInvocableWithPrototype< typename Decay<FUNC>::type>::value; ---- [.small]#xref:bsl/function-0a/2constructor-0e.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#