A simplified 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.
More...
#include <any.h>
|
| Value (Value &&)=default |
| Move construction and assignment is allowed, and follows the default behavior of move for std::unique_ptr . More...
|
|
Value & | operator= (Value &&)=default |
|
| Value (const Value &other)=delete |
| Copy is disallowed, because we don't need it.
|
|
Value & | operator= (const Value &other)=delete |
|
template<typename T > |
T * | try_get () |
| Returns a pointer to the value contained in the Value if the type passed as template parameter matches the type of the value stored, and returns a null pointer otherwise. More...
|
|
template<typename T > |
T | get () |
| Returns the value contained in the Value if the type passed as template parameter matches the type of the value stored, and throws an exception otherwise. More...
|
|
const std::type_info & | type_info () const noexcept |
| Returns the type_info object of the contained value.
|
|
|
class | AnyModule |
|
struct | TestValue |
|
A simplified 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.
It is simplified in that it does not handle copying, as we do not require it for our use cases. Moves are sufficient.
Definition at line 235 of file any.h.
torch::nn::AnyModule::Value::Value |
( |
Value && |
| ) |
|
|
default |
Move construction and assignment is allowed, and follows the default behavior of move for std::unique_ptr
.
template<typename T >
T torch::nn::AnyModule::Value::get |
( |
| ) |
|
|
inline |
Returns the value contained in the Value
if the type passed as template parameter matches the type of the value stored, and throws an exception otherwise.
Definition at line 267 of file any.h.
template<typename T >
T* torch::nn::AnyModule::Value::try_get |
( |
| ) |
|
|
inline |
Returns a pointer to the value contained in the Value
if the type passed as template parameter matches the type of the value stored, and returns a null pointer otherwise.
Definition at line 250 of file any.h.
The documentation for this class was generated from the following file:
- torch/csrc/api/include/torch/nn/modules/any.h