A type-erased container for any copyable value.
More...
#include <peak_common/types/peak_common_any.hpp>
|
| | 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.
|
| PEAK_COMMON_NO_DISCARD 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> |
| PEAK_COMMON_NO_DISCARD const T & | AnyCast () const |
| | Const version of AnyCast.
|
| PEAK_COMMON_NO_DISCARD 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.
- Since
- ids_peak_common 1.0
◆ Any() [1/5]
| peak::common::Any::Any |
( |
| ) |
|
|
default |
Default constructor. Constructs an empty Any object.
- Since
- ids_peak_common 1.0
◆ Any() [2/5]
template<typename T>
| peak::common::Any::Any |
( |
const T & | value | ) |
|
|
inlineexplicit |
Constructs an Any from a const reference.
- Template Parameters
-
| T | The type of the value to store. |
- Parameters
-
- Since
- ids_peak_common 1.0
◆ Any() [3/5]
template<typename T>
| peak::common::Any::Any |
( |
T && | value | ) |
|
|
inlineexplicit |
Constructs an Any from a rvalue reference.
- Template Parameters
-
| T | The type of the value to store. |
- Parameters
-
- Since
- ids_peak_common 1.0
◆ Any() [4/5]
| peak::common::Any::Any |
( |
const Any & | other | ) |
|
|
inline |
Copy constructor.
- Since
- ids_peak_common 1.0
◆ Any() [5/5]
| peak::common::Any::Any |
( |
Any && | other | ) |
|
|
defaultnoexcept |
Move constructor.
- Since
- ids_peak_common 1.0
◆ AnyCast() [1/2]
template<typename T>
| T & peak::common::Any::AnyCast |
( |
| ) |
|
|
inline |
Casts the stored value to the specified type.
- Template Parameters
-
| T | The expected type of the stored value. |
- Returns
- Reference to the value.
- Exceptions
-
- Since
- ids_peak_common 1.0
◆ AnyCast() [2/2]
Const version of AnyCast.
- Template Parameters
-
| T | The expected type of the stored value. |
- Returns
- Const reference to the value.
- Exceptions
-
- Since
- ids_peak_common 1.0
◆ GetType()
Gets the type of the stored value.
- Returns
- Type info of the stored value, or typeid(void) if empty.
- Since
- ids_peak_common 1.0
◆ HasValue()
Checks if the Any contains a value.
- Returns
- True if a value is stored, false otherwise.
- Since
- ids_peak_common 1.0
◆ operator=() [1/2]
| Any & peak::common::Any::operator= |
( |
Any && | other | ) |
|
|
defaultnoexcept |
Move assignment operator.
- Since
- ids_peak_common 1.0
◆ operator=() [2/2]
| Any & peak::common::Any::operator= |
( |
const Any & | other | ) |
|
|
inline |
Copy assignment operator.
- Since
- ids_peak_common 1.0
◆ Reset()
| void peak::common::Any::Reset |
( |
| ) |
|
|
inline |
Clears the stored value.
- Since
- ids_peak_common 1.0
The documentation for this class was generated from the following file: