This utility struct provides a namespace for several types, type traits, and constants used in the implementation of the small-object optimization for bsl::function.
Declared in <bslstl_function_smallobjectoptimization.h>
class Function_SmallObjectOptimization;
| Name | Description |
|---|---|
InplaceBuffer | This union defines the storage area for a functor representation. The design uses the small-object optimization in an attempt to avoid allocations for objects that are no larger than InplaceBuffer. When the target object is no larger than InplaceBuffer, the small-object optimization can be used by storing the target directly within the InplaceBuffer. |
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.e., using the small-object optimization.) |
SooFuncSize | This class template provides a metafunction that bsl::function uses to determine the size of an object, and whether to store it using the small-object optimization (SOO) or not. The value member of this class encodes the size of the specified TP type as follows: |
| Name | Description |
|---|---|
k_NON_SOO_SMALL_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.e., because it does not have a nothrow move constructor and cannot, therefore, be swapped safely. When a size larger than this constant is seen, the actual object size can be determined by subtracting this constant. A useful quality of this encoding is that if SZ <= sizeof(InplaceBuffer) for some object size SZ, then SZ + k_NON_SOO_SMALL_SIZE > 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 "is inplace function" simple. Note that it is assumed that no actual object has a size larger than this constant. |