Class AnyValue¶
Defined in File any_value.h
Page Contents
Nested Relationships¶
Class Documentation¶
-
class AnyValue¶
An implementation of
std::any
which stores a type erased object, whose concrete value can be retrieved at runtime by checking if thetypeid()
of a requested type matches thetypeid()
of the object stored.Public Functions
-
AnyValue(AnyValue&&) = default¶
Move construction and assignment is allowed, and follows the default behavior of move for
std::unique_ptr
.
-
~AnyValue() = default¶
-
template<typename T, typename = std::enable_if_t<!std::is_same_v<T, AnyValue>>>
inline explicit AnyValue(T &&value)¶ Constructs the
AnyValue
from value type.
-
template<typename T>
inline T *try_get()¶ Returns a pointer to the value contained in the
AnyValue
if the type passed as template parameter matches the type of the value stored, and returns a null pointer otherwise.
-
template<typename T>
inline T get()¶ Returns the value contained in the
AnyValue
if the type passed as template parameter matches the type of the value stored, and throws an exception otherwise.
-
inline const std::type_info &type_info() const noexcept¶
Returns the
type_info
object of the contained value.
-
AnyValue(AnyValue&&) = default¶