Shortcuts

Class AnyValue

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 the typeid() of a requested type matches the typeid() 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 &operator=(AnyValue&&) = default
~AnyValue() = default
inline AnyValue(const AnyValue &other)

Copy construction and assignment is allowed.

inline AnyValue &operator=(const AnyValue &other)
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.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources