Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/wrapper.hpp"
Universal value/ref wrapper accessible similar to a pointer.
A copyable, assignable value object to hold a given value within an embedded inline buffer. It can be default constructed and bool
evaluated to detect an empty holder. The value is retrieved through a pointer-like interface, by explicit dereferentiation. (Contrast this to std::ref, where the original reference is retrieved by conversion).
The purpose of this template is to be able to remember pretty much any kind of value or pointer or reference, and to subsume this handling within a single template. An example would be to remember the value yielded by a function, without any further assumptions regarding this function.
Definition at line 111 of file wrapper.hpp.
Public Member Functions | |
ItemWrapper (TY const &o) | |
ItemWrapper (TY &&ro) | |
ItemWrapper (ItemWrapper const &ref) | |
ItemWrapper (ItemWrapper &&rref) | |
ItemWrapper & | defaultInit () |
implant a default-initialised instance of the payload type | |
bool | isValid () const |
operator bool () const | |
TY & | operator* () const |
TY * | operator-> () const |
ItemWrapper & | operator= (ItemWrapper const &cref) |
ItemWrapper & | operator= (ItemWrapper &ref) |
ItemWrapper & | operator= (ItemWrapper &&rref) |
template<typename X > | |
ItemWrapper & | operator= (X &&something) |
Emulate »assignment« by discarding and then construction of a new payload. More... | |
void | reset () |
Private Types | |
using | TY_unconst = std::remove_const_t< TY > |
Private Member Functions | |
TY & | access () const |
TY_unconst & | access_unconst () const |
< used to assign new buffer contents | |
template<typename REF > | |
void | build (REF &&ref) |
void | discard () |
Private Attributes | |
std::byte | content_ [sizeof(TY)] |
bool | created_ |
|
inline |
Emulate »assignment« by discarding and then construction of a new payload.
something | from which TY can be (copy/move)constructed |
Definition at line 230 of file wrapper.hpp.