[#bsl-function-0a] = xref:bsl.adoc[bsl]::function :relfileprefix: ../ :mrdocs: Forward declaration. == Synopsis Declared in `<bslstl_function.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class PROTOTYPE> class function : public xref:BloombergLP/bslstl/Function_Variadic-0e.adoc[BloombergLP::bslstl::Function_Variadic<PROTOTYPE>] ---- == Base Classes [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bslstl/Function_Variadic-0e.adoc[BloombergLP::bslstl::Function_Variadic<PROTOTYPE>]` | This component‐private class template contains the physical representation and provides the variadic interfaces for `bsl::function`. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:bsl/function-0a/allocator_type.adoc[`allocator_type`] | Alias for the allocator type of the function representation. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/function-0a/2constructor-075.adoc[`function`] [.small]#[constructor]# | Constructors | xref:bsl/function-0a/operator_assign-01.adoc[`operator=`] | Assignment operators | xref:bsl/function-0a/allocator.adoc[`allocator`] | Return `get_allocator().mechanism()`. Note that this function exists for BDE compatibility and is not part of the C++ Standard Library. | xref:bsl/function-0a/get_allocator.adoc[`get_allocator`] | Return (a copy of) the allocator used to supply memory for this `function`. | xref:bsl/function-0a/isInplace.adoc[`isInplace`] | Return `true` if this `function` is empty or if it is non‐empty and its target qualifies for the small‐object optimization (and is thus allocated within this object's footprint); otherwise, return false. | xref:bsl/function-0a/swap.adoc[`swap`] | Exchange the targets held by this `function` and the specified `other` `function`. The behavior is undefined unless `get_allocator() == other.get_allocator()`. | xref:bsl/function-0a/target-0a9.adoc[`target`] | `target` overloads | xref:bsl/function-0a/target_type.adoc[`target_type`] | Return `typeid(void)` if this object is empty; otherwise `typeid(FUNC)` where `FUNC` is the type of the target object. | xref:bsl/function-0a/2conversion-05.adoc[`operator BloombergLP::bdef_Function<PROTOTYPE*>&`] | Return `*this`, converted to a mutable `bdef_Function` reference by downcasting. The behavior is undefined unless `bdef_Function<F*>` is derived from `bsl::function<F>` and adds no new data members. | xref:bsl/function-0a/2conversion-0d.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<function, UsesAllocatorArgT>`] | Nested trait declaration for `bslmf::UsesAllocatorArgT`. | xref:bsl/function-0a/2conversion-0a.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<function, UsesBslmaAllocator>`] | Nested trait declaration for `bslma::UsesBslmaAllocator`. | xref:bsl/function-0a/2conversion-07.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<function, is_nothrow_move_constructible>`] | Nested trait declaration for `is_nothrow_move_constructible`. | xref:bsl/function-0a/2conversion-03.adoc[`operator bool`] | (C++11 and later) Return false if this object is empty, otherwise return true. Note that this is an explicit conversion operator and is typically invoked implicitly in contexts such as in the condition of an `if` or `while` statement, though it can also be invoked via an explicit cast. | xref:bsl/function-0a/2conversion-0c.adoc[`operator BloombergLP::bdef_Function<PROTOTYPE*> const&`] | Return `*this` converted to a const `bdef_Function` reference by downcasting. The behavior is undefined unless `bdef_Function<F*>` is derived from `bsl::function<F>` and adds no new data members. |=== == Using Declarations [cols="1,4"] |=== | Name| Description | xref:bsl/function-0a/operator().adoc[`operator()`] | If this object is empty, throw `bsl::bad_function_call`; otherwise invoke the target object with the specified `args...` and return the result (after conversion to `RET`). Note that, even though it is declared `const`, this call operator can mutate the target object and is thus considered a manipulator rather than an accessor. |=== == Deduction Guides [cols="1,4"] |=== | Name| Description | xref:bsl/function-00.adoc[`function<PROTOTYPE>`] | Deduce the template parameter `PROTOTYPE` from the signature of the `operator()` of the functor supplied to the constructor of `function`. | xref:bsl/function-066.adoc[`function<PROTOTYPE>`] | Deduce the template parameter `PROTOTYPE` from the signature of the `operator()` of the functor supplied to the constructor of `function`. | xref:bsl/function-06d.adoc[`function<RET(ARGS...)>`] | Deduce the template parameter `PROTOTYPE` from the signature of the function supplied to the constructor of `function`. | xref:bsl/function-05.adoc[`function<RET(ARGS...)>`] | Deduce the template parameter `PROTOTYPE` from the signature of the function supplied to the constructor of `function`. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/operator_not_eq-0b.adoc[`operator!=`] | Return `true` if the specified `function` is not empty. | xref:bsl/operator_eq-09d2.adoc[`operator==`] | Return true if the specified `function` argument is empty, otherwise return false. | xref:bsl/swap-026.adoc[`swap`] | Exchange the targets held by the specified `a` and specified `b` objects. The behavior is undefined unless 'a.get_allocator() == b.get_allocator()'. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#