#include <peak_common/types/peak_common_any.hpp>
Public Member Functions | |
| Any ()=default | |
| Default constructor. Constructs an empty Any object. | |
| template<typename T > | |
| Any (const T &value) | |
| Constructs an Any from a const reference. | |
| template<typename T > | |
| Any (T &&value) | |
| Constructs an Any from a rvalue reference. | |
| Any (const Any &other) | |
| Copy constructor. | |
| Any (Any &&other) noexcept=default | |
| Move constructor. | |
| Any & | operator= (const Any &other) |
| Copy assignment operator. | |
| Any & | operator= (Any &&other) noexcept=default |
| Move assignment operator. | |
| void | Reset () |
| Clears the stored value. | |
| const std::type_info & | GetType () const |
| Gets the type of the stored value. | |
| template<typename T > | |
| T & | AnyCast () |
| Casts the stored value to the specified type. | |
| template<typename T > | |
| const T & | AnyCast () const |
| Const version of AnyCast. | |
| bool | HasValue () const |
| Checks if the Any contains a value. | |
A type-erased container for any copyable value.
This class provides a way to store and retrieve a value of arbitrary type using type erasure. It behaves similarly to std::any and allows type-safe casting via the AnyCast<T>() method.
Definition at line 35 of file peak_common_any.hpp.
|
inlineexplicit |
Constructs an Any from a const reference.
| T | The type of the value to store. |
| value | The value to store. |
Definition at line 88 of file peak_common_any.hpp.
|
inlineexplicit |
Constructs an Any from a rvalue reference.
| T | The type of the value to store. |
| value | The value to store. |
Definition at line 101 of file peak_common_any.hpp.
|
inline |
Casts the stored value to the specified type.
| T | The expected type of the stored value. |
| InvalidCastException | if the types do not match. |
Definition at line 179 of file peak_common_any.hpp.
|
inline |
Const version of AnyCast.
| T | The expected type of the stored value. |
| InvalidCastException | if the types do not match. |
Definition at line 201 of file peak_common_any.hpp.
|
inline |
Gets the type of the stored value.
typeid(void) if empty.Definition at line 164 of file peak_common_any.hpp.
|
inline |
Checks if the Any contains a value.
Definition at line 220 of file peak_common_any.hpp.
Copy assignment operator.
Definition at line 131 of file peak_common_any.hpp.
|
inline |
Clears the stored value.
Definition at line 152 of file peak_common_any.hpp.