![]() |
|
Used to implement small object optimizations for the type-erasure (Any) pattern. More...
#include <fixedSizePolymorphicHolder.h>
Public Member Functions | |
| Vdf_FixedSizePolymorphicHolder (Vdf_FixedSizePolymorphicHolder const &)=delete | |
| Vdf_FixedSizePolymorphicHolder & | operator= (Vdf_FixedSizePolymorphicHolder const &)=delete |
| template<class Derived , class ... Args> | |
| void | New (Args &&... args) |
| Creates an instance. | |
| void | Destroy () |
| Destroys a held instance. | |
| Base const * | Get () const |
| Returns a Base pointer to the held instance. | |
| Base * | Get () |
| Returns a Base pointer to the held instance. | |
Used to implement small object optimizations for the type-erasure (Any) pattern.
This class allows clients to instantiate polymorphic objects into a fixed buffer space. If code attempts to instantiate an object that is too large to fit in the allotted space, that code will generate a compile-time error. Additionally, any instance of a derived class stored in this holder must have its Base object at the same address. Practically speaking, this means that multiple inheritance isn't supported. Currently this requirement is enforced only at runtime.
Definition at line 36 of file fixedSizePolymorphicHolder.h.
|
inline |
Destroys a held instance.
Invokes ~Base on the held object. A valid instance of type Base or a type derived from Base must already be held.
Definition at line 81 of file fixedSizePolymorphicHolder.h.
|
inline |
Returns a Base pointer to the held instance.
Definition at line 98 of file fixedSizePolymorphicHolder.h.
|
inline |
Returns a Base pointer to the held instance.
Definition at line 93 of file fixedSizePolymorphicHolder.h.
|
inline |
Creates an instance.
Uses placement-new to create an object of type Derived into the local storage. Will fail to compile if Derived's size or alignment is incompatible with the storage.
Definition at line 59 of file fixedSizePolymorphicHolder.h.