type erased data container
More...
#include <data.hpp>
|
|
| data () |
| | default constructor
|
| |
|
| data (data &&rhs) |
| | rvalue constructor
|
| |
|
data & | operator= (data &&rhs) |
| | rvalue copy
|
| |
|
| data (const data &rhs)=delete |
| | no lvalue constructor or copy
|
| |
|
data & | operator= (const data &rhs)=delete |
| |
| | operator bool () const |
| |
| const std::type_info & | type_info () const |
| |
| template<typename T > |
| bool | is () const |
| | determine at runtime whether the type erased data type code matches the templated type code. More...
|
| |
| void * | get () |
| |
| template<typename T > |
| T & | cast_to () |
| | cast message data payload to templated type reference More...
|
| |
| template<typename T > |
| bool | copy_to (T &t) |
| | copy the data payload to argument t More...
|
| |
| template<typename T > |
| bool | move_to (T &t) |
| | rvalue swap the data payload to argument t More...
|
| |
|
| template<typename T , typename... As> |
| static data | make (As &&... as) |
| | construct a data payload using explicit template typing instead of by deduction More...
|
| |
type erased data container
The purpose of this object is similar to c++17 std::any but is backwards compatible to c++11. It is intended to be constructed inside other objects in this library (st::message) instead of directly by the user.
st::data can represent types that are at least lvalue constructable.
◆ cast_to()
cast message data payload to templated type reference
NOTE: this function is NOT type checked. A successful call to is<T>() is required before casting to ensure type safety. It is typically better practice and generally safer to use copy_to<T>() or move_to<T>(), which include an internal type check.
- Returns
- a reference of type T to the dereferenced void pointer payload
◆ copy_to()
template<typename T >
| bool st::data::copy_to |
( |
T & |
t | ) |
|
|
inline |
copy the data payload to argument t
- Parameters
-
| t | reference to templated variable t to deep copy the payload data to |
- Returns
- true on success, false on type mismatch
◆ get()
- Returns
- the internal payload pointer
◆ is()
template<typename T >
| bool st::data::is |
( |
| ) |
const |
|
inline |
determine at runtime whether the type erased data type code matches the templated type code.
- Returns
- true if the unqualified type of T matches the data type, else false
◆ make()
template<typename T , typename... As>
| static data st::data::make |
( |
As &&... |
as | ) |
|
|
inlinestatic |
construct a data payload using explicit template typing instead of by deduction
- Parameters
-
| as | optional constructor parameters |
- Returns
- an allocated data object
◆ move_to()
template<typename T >
| bool st::data::move_to |
( |
T & |
t | ) |
|
|
inline |
rvalue swap the data payload to argument t
- Parameters
-
| t | reference to templated variable t to rvalue swap the payload data to |
- Returns
- true on success, false on type mismatch
◆ operator bool()
| st::data::operator bool |
( |
| ) |
const |
|
inline |
- Returns
true if the object represents an allocated data payload, else false
◆ type_info()
| const std::type_info& st::data::type_info |
( |
| ) |
const |
|
inline |
If st::data has not been constructed with a payload value then returned type_info will be equal to typeid(st::data::unset).
- Returns
- payload type info
The documentation for this struct was generated from the following file: