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

This utility `struct` provides a namespace for several types, type traits, and constants used in the implementation of the small&hyphen;object optimization for `bsl&colon;&colon;function`&period;

== Synopsis

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

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

== Types

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/Function_SmallObjectOptimization/InplaceBuffer.adoc[`InplaceBuffer`] 
| This `union` defines the storage area for a functor representation&period; The design uses the small&hyphen;object optimization in an attempt to avoid allocations for objects that are no larger than `InplaceBuffer`&period; When the target object is no larger than `InplaceBuffer`, the small&hyphen;object optimization can be used by storing the target directly within the `InplaceBuffer`&period;
| xref:BloombergLP/bslstl/Function_SmallObjectOptimization/IsInplaceFunc.adoc[`IsInplaceFunc`] 
| This class is a Boolean metafunction that determines whether or not the specified `FN` template parameter should be allocated within the footprint of the `InplaceBuffer` (i&period;e&period;, using the small&hyphen;object optimization&period;)
| xref:BloombergLP/bslstl/Function_SmallObjectOptimization/SooFuncSize.adoc[`SooFuncSize`] 
| This class template provides a metafunction that `bsl&colon;&colon;function` uses to determine the size of an object, and whether to store it using the small&hyphen;object optimization (SOO) or not&period; The `value` member of this class encodes the size of the specified `TP` type as follows&colon;
|===


== Static Data Members

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/Function_SmallObjectOptimization/k_NON_SOO_SMALL_SIZE.adoc[`k&lowbar;NON&lowbar;SOO&lowbar;SMALL&lowbar;SIZE`] 
| `SooFuncSize` (below) adds this value to the size of a small stateful functor to indicate that, despite being small, it should not be allocated inplace using the small object optimization (SOO), i&period;e&period;, because it does not have a nothrow move constructor and cannot, therefore, be swapped safely&period; When a size larger than this constant is seen, the actual object size can be determined by subtracting this constant&period; A useful quality of this encoding is that if `SZ &lt;&equals; sizeof(InplaceBuffer)` for some object size `SZ`, then `SZ &plus; k&lowbar;NON&lowbar;SOO&lowbar;SMALL&lowbar;SIZE &gt; sizeof(InplaceBuffer)`, thus `SooFuncSize` (below) for any object that should not be allocated inplace is larger than `sizeof(InplaceBuffer)`, and the `SooFuncSize` for any object that _should_ be allocated inplace is smaller than or equal to `sizeof(InplaceBuffer)`, making the test for &quot;is inplace function&quot; simple&period; Note that it is assumed that no actual object has a size larger than this constant&period;
|===



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