matlab::data::optional<T>
Templated C++ class representing optional values
Description
Use optional
objects to represent values that might or might not
exist.
Class Details
Namespace: | matlab::data |
Include: |
|
Template Parameters
|
Array type, specified as
|
Constructors
Default Constructors
optional()
Copy Constructors
optional(const optional& other)
Creates a shared data copy.
|
Value to copy. |
None
Copy Assignment Operators
optional<T>& operator=(const optional<T>& other)
Assigns a shared data copy.
|
Value to copy. |
|
Updated instance. |
None
Move Constructors
optional(optional&& other)
optional(T&& value)
Moves contents of an optional
object to a new instance.
|
Value to move. |
| Value of type T to move. |
None
Move Assignment Operators
optional<T>& operator=(optional<T>&& other)
optional<T>& operator=(T&& value)
Assigns the input to this instance.
|
Value to move. |
|
Updated instance. |
None
Other Operators
operator=
optional<T>& operator=(nullopt_t)
optional<T>& operator=(const optional<T>& other)
optional<T>& operator=(optional<T>&& other)
optional<T>& operator=(T&& value)
optional<T>& operator=(const T& value)
Assignment operators.
|
Updated instance. |
None
operator->
const T* operator->() const
T* operator->()
|
Pointer to the element. |
|
|
operator*
const T& operator*() const
T& operator*()
| Reference to the element. |
|
|
operator T
operator T() const
Cast optional<T>
value to T
.
|
Value contained in |
|
There is no value. |
Member Functions
bool
explicit operator bool() const
Check whether object contains a value.
|
True, if object contains a value. |
None
has_value
bool has_value() const
Check whether object contains a value.
|
True, if object contains a value. |
None
swap
void swap(optional &other)
Swap value of this optional instance with value contained in the parameter.
|
Value to swap. |
None
reset
void reset()
Reset optional value to missing
None
Version History
Introduced in R2017b