[#BloombergLP-bslstl-Function_Rep] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::Function_Rep :relfileprefix: ../../ :mrdocs: This is a component‐private class. Do not use. == Synopsis Declared in `<bslstl_function_rep.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class Function_Rep; ---- == Description This class provides a non‐template representation for a `bsl::function` instance. It handles all of the object‐management parts of `bsl::function` that are not specific to the prototype (argument list and return type), e.g., storing, copying, and moving the `function` object, but not invoking the `function` (which requires knowledge of the prototype). These management methods are run‐time polymorphic, and therefore do not require that this class be a template (although several of the member functions are templates). == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslstl/Function_Rep/GenericInvoker.adoc[`GenericInvoker`] | A "generic" function type analogous to the data type `void` (though without the language support provided by `void`). | xref:BloombergLP/bslstl/Function_Rep/allocator_type.adoc[`allocator_type`] | This class does not conform to any specific interface so is not allocator‐aware in the strict sense. However, this type does hold an allocator for its AA client and therefore uses the type name for the allocator preferred by AA types. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bslstl/Function_Rep/2constructor.adoc[`Function_Rep`] [.small]#[constructor]# | Create an empty object using the specified `allocator` to supply memory. | xref:BloombergLP/bslstl/Function_Rep/2destructor.adoc[`~Function_Rep`] [.small]#[destructor]# | Destroy this object and its target object (if any) and deallocate memory for the target object (if not in‐place). This destructor is implemented to correctly deallocate a target object that has been allocated but not constructed (e.g., if an exception is thrown while constructing the target). | xref:BloombergLP/bslstl/Function_Rep/copyInit.adoc[`copyInit`] | Copy‐initialize this rep from the specified `original` rep. If an exception is thrown by the copy, the only valid subsequent operation on this object is destruction. The behavior is undefined unless this object is empty before the call. | xref:BloombergLP/bslstl/Function_Rep/get_allocator.adoc[`get_allocator`] | Return the allocator used to supply memory for this object. | xref:BloombergLP/bslstl/Function_Rep/installFunc.adoc[`installFunc`] | Do nothing if the specified `func` is a null pointer, otherwise allocate storage (either in‐place within this object's small‐object buffer or out‐of‐place from the allocator) to hold a target of (template parameter) type `FUNC`, forward the `func` to the constructor of the new target, set `d_funcManager_p` to manage the new target, and set `d_invoker_p` to the specified `invoker` address. The behavior is undefined unless this object is empty on entry. Note that `FUNC` will not qualify for the small‐object optimization unless `bsl::is_nothrow_move_constructible<FUNC>::value` is `true`. | xref:BloombergLP/bslstl/Function_Rep/invoker.adoc[`invoker`] | Return a pointer the invoker function set using `installFunc` or a null pointer if this object is empty. | xref:BloombergLP/bslstl/Function_Rep/isEmpty.adoc[`isEmpty`] | Return `true` if `invoker()` is a null pointer, indicating that this object has no target object. | xref:BloombergLP/bslstl/Function_Rep/isInplace.adoc[`isInplace`] | Return `true` if the target is allocated in place within the small‐object buffer of this object; otherwise return `false`. | xref:BloombergLP/bslstl/Function_Rep/makeEmpty.adoc[`makeEmpty`] | Change this object to be an empty object without changing its allocator. Any previous target is destroyed and deallocated. Note that value returned by `get_allocator().mechanism()` might change, but will point to an allocator with the same type managing the same memory resource. | xref:BloombergLP/bslstl/Function_Rep/moveInit.adoc[`moveInit`] | Move‐initialize this rep from the rep at the specified `from` address, leaving the latter empty. If 'this‐>get_allocator() != from‐>get_allocator()', this function degenerates to a call to `copyInit(*from)`. The behavior is undefined unless this rep is empty before the call. | xref:BloombergLP/bslstl/Function_Rep/swap.adoc[`swap`] | Exchange this object's target object, manager function, and invoker with those of the specified `other` object. The behavior is undefined unless `this‐>get_allocator() == other‐>get_allocator()`. | xref:BloombergLP/bslstl/Function_Rep/target.adoc[`target`] | If `typeid(TP) == this‐>target_type()`, return a pointer offering modifiable access to this object's target; otherwise return a null pointer. Note that this function is `const` but returns a non‐`const` pointer because, according to the C++ Standard, `function` (and therefore this representation) does not adhere to logical constness conventions. | xref:BloombergLP/bslstl/Function_Rep/targetRaw.adoc[`targetRaw`] | Return a pointer offering modifiable access to this object's target. If `INPLACE` is true, then the object is assumed to be allocated inplace in the small object buffer. Note that this function is `const` but returns a non‐`const` pointer because this type does not adhere to logical constness conventions. The behavior is undefined unless `typeid(TP) == this‐>target_type()` and `INPLACE` correctly identifies whether the target is inplace. | xref:BloombergLP/bslstl/Function_Rep/target_type.adoc[`target_type`] | Return a reference to the `type_info` for the type of the current target object or `typeid(void)` if this object is empty. If the target type is a specialization of `bslalg::NothrowMovableWrapper`, then the returned `type_info` is for the unwrapped type. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#