[#BloombergLP-bslstl-Function_Rep]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::Function&lowbar;Rep
:relfileprefix: ../../
:mrdocs:

This is a component&hyphen;private class&period; Do not use&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class Function&lowbar;Rep;
----

== Description

This class provides a non&hyphen;template representation for a `bsl&colon;&colon;function` instance&period; It handles all of the object&hyphen;management parts of `bsl&colon;&colon;function` that are not specific to the prototype (argument list and return type), e&period;g&period;, storing, copying, and moving the `function` object, but not invoking the `function` (which requires knowledge of the prototype)&period; These management methods are run&hyphen;time polymorphic, and therefore do not require that this class be a template (although several of the member functions are templates)&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/Function_Rep/GenericInvoker.adoc[`GenericInvoker`] 
| A &quot;generic&quot; function type analogous to the data type `void` (though without the language support provided by `void`)&period;
| xref:BloombergLP/bslstl/Function_Rep/allocator_type.adoc[`allocator&lowbar;type`] 
| This class does not conform to any specific interface so is not allocator&hyphen;aware in the strict sense&period; However, this type does hold an allocator for its AA client and therefore uses the type name for the allocator preferred by AA types&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/Function_Rep/2constructor.adoc[`Function&lowbar;Rep`]         [.small]#[constructor]#
| Create an empty object using the specified `allocator` to supply memory&period;
| xref:BloombergLP/bslstl/Function_Rep/2destructor.adoc[`&#126;Function&lowbar;Rep`] [.small]#[destructor]#
| Destroy this object and its target object (if any) and deallocate memory for the target object (if not in&hyphen;place)&period; This destructor is implemented to correctly deallocate a target object that has been allocated but not constructed (e&period;g&period;, if an exception is thrown while constructing the target)&period;
| xref:BloombergLP/bslstl/Function_Rep/copyInit.adoc[`copyInit`] 
| Copy&hyphen;initialize this rep from the specified `original` rep&period; If an exception is thrown by the copy, the only valid subsequent operation on this object is destruction&period; The behavior is undefined unless this object is empty before the call&period;
| xref:BloombergLP/bslstl/Function_Rep/get_allocator.adoc[`get&lowbar;allocator`] 
| Return the allocator used to supply memory for this object&period;
| xref:BloombergLP/bslstl/Function_Rep/installFunc.adoc[`installFunc`] 
| Do nothing if the specified `func` is a null pointer, otherwise allocate storage (either in&hyphen;place within this object&apos;s small&hyphen;object buffer or out&hyphen;of&hyphen;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&lowbar;funcManager&lowbar;p` to manage the new target, and set `d&lowbar;invoker&lowbar;p` to the specified `invoker` address&period; The behavior is undefined unless this object is empty on entry&period; Note that `FUNC` will not qualify for the small&hyphen;object optimization unless `bsl&colon;&colon;is&lowbar;nothrow&lowbar;move&lowbar;constructible&lt;FUNC&gt;&colon;&colon;value` is `true`&period;
| 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&period;
| xref:BloombergLP/bslstl/Function_Rep/isEmpty.adoc[`isEmpty`] 
| Return `true` if `invoker()` is a null pointer, indicating that this object has no target object&period;
| xref:BloombergLP/bslstl/Function_Rep/isInplace.adoc[`isInplace`] 
| Return `true` if the target is allocated in place within the small&hyphen;object buffer of this object&semi; otherwise return `false`&period;
| xref:BloombergLP/bslstl/Function_Rep/makeEmpty.adoc[`makeEmpty`] 
| Change this object to be an empty object without changing its allocator&period; Any previous target is destroyed and deallocated&period; Note that value returned by `get&lowbar;allocator()&period;mechanism()` might change, but will point to an allocator with the same type managing the same memory resource&period;
| xref:BloombergLP/bslstl/Function_Rep/moveInit.adoc[`moveInit`] 
| Move&hyphen;initialize this rep from the rep at the specified `from` address, leaving the latter empty&period; If &apos;this&hyphen;&gt;get&lowbar;allocator() !&equals; from&hyphen;&gt;get&lowbar;allocator()&apos;, this function degenerates to a call to `copyInit(&ast;from)`&period; The behavior is undefined unless this rep is empty before the call&period;
| xref:BloombergLP/bslstl/Function_Rep/swap.adoc[`swap`] 
| Exchange this object&apos;s target object, manager function, and invoker with those of the specified `other` object&period; The behavior is undefined unless `this&hyphen;&gt;get&lowbar;allocator() &equals;&equals; other&hyphen;&gt;get&lowbar;allocator()`&period;
| xref:BloombergLP/bslstl/Function_Rep/target.adoc[`target`] 
| If `typeid(TP) &equals;&equals; this&hyphen;&gt;target&lowbar;type()`, return a pointer offering modifiable access to this object&apos;s target&semi; otherwise return a null pointer&period; Note that this function is `const` but returns a non&hyphen;`const` pointer because, according to the C&plus;&plus; Standard, `function` (and therefore this representation) does not adhere to logical constness conventions&period;
| xref:BloombergLP/bslstl/Function_Rep/targetRaw.adoc[`targetRaw`] 
| Return a pointer offering modifiable access to this object&apos;s target&period; If `INPLACE` is true, then the object is assumed to be allocated inplace in the small object buffer&period; Note that this function is `const` but returns a non&hyphen;`const` pointer because this type does not adhere to logical constness conventions&period; The behavior is undefined unless `typeid(TP) &equals;&equals; this&hyphen;&gt;target&lowbar;type()` and `INPLACE` correctly identifies whether the target is inplace&period;
| xref:BloombergLP/bslstl/Function_Rep/target_type.adoc[`target&lowbar;type`] 
| Return a reference to the `type&lowbar;info` for the type of the current target object or `typeid(void)` if this object is empty&period; If the target type is a specialization of `bslalg&colon;&colon;NothrowMovableWrapper`, then the returned `type&lowbar;info` is for the unwrapped type&period;
|===



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