template<class BA, size_t siz = sizeof(BA), class DEFAULT = BA>
class lib::InPlaceBuffer< BA, siz, DEFAULT >
Buffer to place and maintain an object instance privately within another object.
Variation of a similar concept as with OpaqueHolder, but implemented here with reduced security and lesser overhead. InPlaceBuffer is just a chunk of storage, which can be accessed through a common base class interface and allows to place new objects there. It has no way to keep track of the actual object living currently in the buffer. Thus, using InPlaceBuffer requires the placed class(es) themselves to maintain their lifecycle, and especially it is mandatory for the base class to provide a virtual dtor. On the other hand, just the (alignment rounded) storage for the object(s) placed into the buffer is required.
- Warning
- InPlaceBuffer really takes ownership, and even creates a default constructed instance of the base class right away. Yet the requirement for a virtual dtor is deliberately not enforced here, to allow use for types without VTable.
- Template Parameters
-
BA | the nominal Base/Interface class for a family of types |
siz | maximum storage required for the targets to be held inline |
DEFAULT | the default instance to place initially |
Definition at line 606 of file opaque-holder.hpp.
|
template<class SUB > |
| InPlaceBuffer (SUB &&instance) |
| immediately move-emplace an embedded subclass type
|
|
template<class TY , typename... ARGS> |
| InPlaceBuffer (TypeTag< TY >, ARGS &&...args) |
| immediately emplace an embedded subclass type
|
|
template<class SUB > |
SUB * | access () |
|
template<class TY , typename... ARGS> |
TY & | create (ARGS &&...args) |
| Abbreviation for placement new.
|
|
template<class SUB > |
SUB & | emplace (SUB &&implementation) |
| move-construct an instance of subclass into the opaque buffer
|
|
BA & | operator* () const |
|
BA * | operator-> () const |
|
DEFAULT & | reset () |
|