|
Bifrost SDK
Bifrost SDK documentation
|
Generic value class that allows for storage of a value of any type. More...
#include <Any.h>
Public Member Functions | |
| Any () noexcept=default | |
| Default constructor. More... | |
| Any (Any const &other)=default | |
| Copy constructor. More... | |
| Any (Any &&other) noexcept=default | |
| Move constructor. More... | |
| template<typename ValueType , typename = Traits::enable_if_valid<ValueType>> | |
| Any (ValueType &&v) noexcept | |
| Move constructor. More... | |
| ~Any ()=default | |
| Destructor. More... | |
| Any & | operator= (Any const &rhs)=default |
| Copy assignment operator. More... | |
| Any & | operator= (Any &&rhs) noexcept=default |
| Move assignment operator. More... | |
| template<typename ValueType , typename = Traits::enable_if_valid<ValueType>> | |
| Any & | operator= (ValueType &&rhs) &noexcept |
| Move assignment conversion. More... | |
| template<typename ValueType , typename... Args, typename = Traits::enable_if_valid<ValueType>, typename = Traits::enable_if_constructible<ValueType, Args...>> | |
| void | emplace (Args &&... args) noexcept |
| Replaces the contained object of this Any. More... | |
| template<typename ValueType , typename Up , typename... Args, typename IL = std::initializer_list<Up>, typename = Traits::enable_if_valid<ValueType>, typename = Traits::enable_if_constructible<ValueType, IL&, Args...>> | |
| void | emplace (std::initializer_list< Up > il, Args &&... args) noexcept |
| Replaces the contained object of this Any. More... | |
| void | reset () noexcept |
| Reset this Any object. More... | |
| Any & | swap (Any &rhs) noexcept |
| Swap payloads with another Any object. More... | |
| bool | has_value () const noexcept |
| Return true if this Any object contains a payload. More... | |
| AMINO_INTERNAL_DEPRECATED ("Use any.type() == other.type() instead.") bool has_same_type(Any const &other) const noexcept | |
| TypeId | type () const noexcept |
Returns the TypeId of the value in this Any, or the TypeId of void if this Any does not have a value. More... | |
Generic value class that allows for storage of a value of any type.
This follows the interface of std::any reasonably closely with the primary difference being no exceptions being thrown – in the case of an invalid cast operation, a default value of the target type will be created and returned. (This event - invalid_cast - may be logged). This has the consequence, in contrast to std::any, that the payload type of Any must have a default constructor. An additional constraint vs std::any is the constness requirements of the payload. Details of this are discussed in the notes below.
Variables of type Any are not completely unlimited in what they can store; there are some minimal preconditions. A value stored in a variable of type Any must be copy-constructible. Therefore, it is not possible for example to store a C array, since C arrays are not copy-constructible.
Unlike std::any, the internals of this class are well defined and known to the Amino compiler, so that it can issue code to properly manipulate these (correctly apply copy, move and destroy semantics) as they are passed into, out from, and through the Amino graph.
For example for an 'elem_count' array of T stored in an Any named 'anyArray', you could use a statement like this;
To retrieve the Ptr to the Array stored in an Any;
|
defaultnoexcept |
Default constructor.
Constructs an empty Any.
has_value() == false Referenced by operator=().
|
default |
|
defaultnoexcept |
|
inlineexplicitnoexcept |
|
default |
Destructor.
Destroys the payload, if any (using reset)
|
inlinenoexcept |
|
inlinenoexcept |
Replaces the contained object of this Any.
Changes the contained object to one of type std::decay_t<ValueType> constructed from the given arguments Args.
First destroys the current contained object (if any) by reset(), then: constructs an object of type std::decay_t<ValueType>, direct-non-list-initialized from std::forward<Args>(args)..., as the contained object.
This overload only participates in overload resolution if ValueType is a valid payload type to be stored in an Any (see Any for details about constraints on payload types) and is constructible from the given arguments args.
|
inlinenoexcept |
Replaces the contained object of this Any.
Changes the contained object to one of type std::decay_t<ValueType> constructed from the given arguments Args.
First destroys the current contained object (if any) by reset(), then: constructs an object of type std::decay_t<ValueType>, direct-non-list-initialized from il, std::forward<Args>(args)..., as the contained object.
This overload only participates in overload resolution if ValueType is a valid payload type to be stored in an Any (see Any for details about constraints on payload types) and is constructible from the given initializer_list il and arguments args.
|
inlinenoexcept |
Copy assignment operator.
The payload of rhs will be copied and the copy will be assigned to this Any.
|
inlinenoexcept |
Move assignment conversion.
rhs is not an Any (or anything that decays into an Any) and is a valid payload type (see Any for details about constraints on payload types).| ValueType | The payload type |
| rhs | The value to assign to this Any |
Definition at line 253 of file Any.h.
References Any().
|
inlinenoexcept |
Reset this Any object.
Causes the contained object to be destroyed (if present).
has_value() == false Swap payloads with another Any object.
Definition at line 314 of file Any.h.
References Amino::swap().
|
inlinenoexcept |
Returns the TypeId of the value in this Any, or the TypeId of void if this Any does not have a value.
Definition at line 329 of file Any.h.
Referenced by AMINO_INTERNAL_DEPRECATED(), and Bifrost::hasProperty().