Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/opaque-holder.hpp"
Inline buffer to hold and own an object while concealing the concrete type.
Access to the contained object is similar to a smart-pointer, but the object isn't heap allocated. OpaqueHolder may be created empty, which can be checked by a bool test. The whole compound is copyable if and only if the contained object is copyable.
OpaqueHolder instances are copyable value objects. They are created either empty, by copy from an existing OpaqueHolder, or by directly specifying the concrete object to embed. This target object will be copy-constructed into the internal buffer. Additionally, you may assign a new value, which causes the old value object to be destroyed and a new one to be copy-constructed into the buffer. Later on, the embedded value might be accessed
isValid()
on the target may be checkedbool
check on the OpaqueHolder instance.For using OpaqueHolder, several assumptions need to be fulfilled
BA | the nominal Base/Interface class for a family of types |
siz | maximum storage required for the targets to be held inline |
Definition at line 530 of file opaque-holder.hpp.
Public Member Functions | |
template<class SUB > | |
OpaqueHolder (SUB const &obj) | |
BA & | operator* () const |
BA * | operator-> () const |
template<class SUB > | |
OpaqueHolder & | operator= (SUB const &newContent) |
Public Member Functions inherited from InPlaceAnyHolder< siz, InPlaceAnyHolder_useCommonBase< BA > > | |
InPlaceAnyHolder (SUB const &obj) | |
InPlaceAnyHolder (InPlaceAnyHolder const &ref) | |
void | clear () |
bool | empty () const |
SUB & | get () const |
re-accessing the concrete contained object. More... | |
bool | isValid () const |
operator bool () const | |
InPlaceAnyHolder & | operator= (InPlaceAnyHolder const &ref) |
InPlaceAnyHolder & | operator= (SUB const &newContent) |
Private Types | |
typedef InPlaceAnyHolder< siz, InPlaceAnyHolder_useCommonBase< BA > > | InPlaceHolder |
Additional Inherited Members | |
Protected Member Functions inherited from InPlaceAnyHolder< siz, InPlaceAnyHolder_useCommonBase< BA > > | |
BaseP | asBase () const |
< More... | |
Buffer & | buff () |
const Buffer & | buff () const |
void | clone_inBuff (InPlaceAnyHolder const &ref) |
void | killBuffer () |
void | make_emptyBuff () |
void | place_inBuff (SUB const &obj) |