![]() |
|
Stores polymorphic objects in a fixed-size buffer. More...
#include <fixedSizePolymorphicHolder.h>
Classes | |
| struct | Compatibility |
Checks if instances of Derived can be stored in this holder. More... | |
Public Types | |
| using | This = EsfFixedSizePolymorphicHolder< Base, BufferSize > |
Public Member Functions | |
| EsfFixedSizePolymorphicHolder ()=delete | |
| The default constructor is deleted because instances must always contain a derived object. | |
| template<class Derived , class... Args> | |
| EsfFixedSizePolymorphicHolder (std::in_place_type_t< Derived > derivedTypeHint, Args &&...args) | |
Construct a holder emplaced with a new Derived instance. | |
| EsfFixedSizePolymorphicHolder (const This &other) | |
| Construct a holder containing a derived type instance that is copy- constructed from another holder. | |
| EsfFixedSizePolymorphicHolder (This &&other) | |
| Construct a holder containing a derived type that is move-constructed from another holder. | |
| ~EsfFixedSizePolymorphicHolder () | |
| Destroys the derived instance held by this object. | |
| This & | operator= (const This &other) |
| Construct a new instance that is copy-constructed from the instance in another holder. | |
| This & | operator= (This &&other) |
| Construct a new instance that is move-constructed from the instance in another holder. | |
Held object accessors | |
Returns a pointer or reference to the held Base instance. | |
| Base * | Get () |
| const Base * | Get () const |
| Base * | operator-> () |
| const Base * | operator-> () const |
| Base & | operator* () |
| const Base & | operator* () const |
Stores polymorphic objects in a fixed-size buffer.
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. Currently this requirement is enforced only at runtime.
Base itself must inherit from EsfFixedSizePolymorphicBase.
Instances of this class always contain a derived object. This class supports copy/move construction and copy/move assignment, so long as the derived type held by the "source" holder also supports copy/move construction. Copying/moving of EsfFixedSizePolymorphicHolders is only supported between identical template specializations (both must have the same Base and BufferSize).
Definition at line 77 of file fixedSizePolymorphicHolder.h.
| using This = EsfFixedSizePolymorphicHolder<Base, BufferSize> |
Definition at line 83 of file fixedSizePolymorphicHolder.h.
|
delete |
The default constructor is deleted because instances must always contain a derived object.
| EsfFixedSizePolymorphicHolder | ( | std::in_place_type_t< Derived > | derivedTypeHint, |
| Args &&... | args | ||
| ) |
Construct a holder emplaced with a new Derived instance.
The Derived type is deduced from the derivedTypeHint parameter, usually passed as std::in_place_type<Derived>. This is necessary because constructors cannot be invoked with explicit template arguments.
The Args are forwarded to the Derived instance's constructor.
Definition at line 244 of file fixedSizePolymorphicHolder.h.
|
inline |
Construct a holder containing a derived type instance that is copy- constructed from another holder.
Definition at line 105 of file fixedSizePolymorphicHolder.h.
|
inline |
Construct a holder containing a derived type that is move-constructed from another holder.
The moved-from holder continues to hold an object, but that object is moved-from.
Definition at line 115 of file fixedSizePolymorphicHolder.h.
|
inline |
Destroys the derived instance held by this object.
Definition at line 121 of file fixedSizePolymorphicHolder.h.
|
inline |
Definition at line 159 of file fixedSizePolymorphicHolder.h.
|
inline |
Definition at line 163 of file fixedSizePolymorphicHolder.h.
|
inline |
Definition at line 175 of file fixedSizePolymorphicHolder.h.
|
inline |
Definition at line 179 of file fixedSizePolymorphicHolder.h.
|
inline |
Definition at line 167 of file fixedSizePolymorphicHolder.h.
|
inline |
Definition at line 171 of file fixedSizePolymorphicHolder.h.
Construct a new instance that is copy-constructed from the instance in another holder.
This holder destroys its current instance before constructing the new instance.
Definition at line 131 of file fixedSizePolymorphicHolder.h.
Construct a new instance that is move-constructed from the instance in another holder.
This holder destroys its current instance before constructing the new instance. The moved-from holder continues to hold an object, but that object is moved-from.
Definition at line 146 of file fixedSizePolymorphicHolder.h.