Struct Nullable
Wrapper for a value type that can be assigned null, controlling the lifetime of the wrapped value.
Assembly: FlaxEngine.dll
File: Engine/Core/Types/Nullable.h
Syntax
public struct Nullable<T>
Type Parameters
T
The type of the wrapped value. It must be move-constructible but does not have to be copy-constructible. Value is never reassigned. |
Constructors
~Nullable()
Declaration
public ~Nullable()
Nullable()
Nullable(const Nullable& other)
Initializes Nullable() by copying another Nullable().
Declaration
public Nullable(const Nullable& other)
Parameters
Nullable
other
The wrapped value to be copied. |
Type Parameters
typename U
|
typename
|
Nullable(const T& value)
Initializes Nullable() by copying the wrapped value.
<NullableBase name="value">The initial wrapped value to be copied.
Declaration
public Nullable(const T& value)
Parameters
T
value
|
Type Parameters
typename U
|
typename
|
Nullable(Nullable&& other)
Initializes Nullable() by moving another Nullable().
Declaration
public Nullable(Nullable&& other) noexcept
Parameters
Nullable
other
The wrapped value to be moved. |
Nullable(T&& value)
Initializes Nullable() by moving the wrapped value.
<NullableBase name="value">The initial wrapped value to be moved.
Declaration
public Nullable(T&& value) noexcept
Parameters
T
value
|
Fields
_dummy
Declaration
public Dummy _dummy
Field Value
Dummy
|
_value
Declaration
public T _value
Field Value
T
|
Methods
GetAndReset(T& value)
Moves the wrapped value to the output parameter and sets the wrapped value to null. If the wrapped value is not valid, the behavior is undefined.
Declaration
public void GetAndReset(T& value)
Parameters
T
value
The output parameter that will receive the wrapped value. |
Returns
void
|
GetValue()
Gets a const reference to the wrapped value. If the value is not valid, the behavior is undefined.
Declaration
public T GetValue() const
Returns
T
Reference to the wrapped value. |
GetValueOr(const T& defaultValue)
Gets a const reference to the wrapped value or a default value if the value is not valid.
Declaration
public T GetValueOr(const T& defaultValue) const
Parameters
T
defaultValue
|
Returns
T
Reference to the wrapped value or the default value. |
GetValueOr(T& defaultValue)
Gets a mutable reference to the wrapped value or a default value if the value is not valid.
Declaration
public T GetValueOr(T& defaultValue) const
Parameters
T
defaultValue
|
Returns
T
Reference to the wrapped value or the default value. |
HasValue()
Checks if wrapped object has a valid value.
Declaration
public bool HasValue() const
Returns
bool
|
Match(ValueVisitor valueHandler, NullVisitor nullHandler)
Matches the wrapped value with a handler for the value or a handler for the null value.
Declaration
public auto Match(ValueVisitor valueHandler, NullVisitor nullHandler) const
Parameters
ValueVisitor
valueHandler
Value visitor handling valid nullable value. |
NullVisitor
nullHandler
Null visitor handling invalid nullable value. |
Returns
auto
Result of the call of one of handlers. Handlers must share the same result type. |
Type Parameters
typename ValueVisitor
|
typename NullVisitor
|
operator bool()
Explicit conversion to boolean value. Allows to check if the wrapped value is valid in if-statements without casting.
Declaration
public operator bool() const
Returns
FORCE_INLINE
|
operator!=(const Nullable& other)
Indicates whether this instance is NOT equal to other one.
Declaration
public bool operator!=(const Nullable& other) const
Parameters
Nullable
other
The other object. |
Returns
bool
|
operator=(const Nullable& other)
Reassigns the wrapped value by copying another Nullable().
Declaration
public Nullable operator=(const Nullable& other)
Parameters
Nullable
other
|
Returns
Nullable
|
Type Parameters
typename U
|
typename
|
operator=(const T& value)
Reassigns the wrapped value by copying.
Declaration
public Nullable operator=(const T& value)
Parameters
T
value
|
Returns
Nullable
|
Type Parameters
typename U
|
typename
|
operator=(Nullable&& other)
Reassigns the wrapped value by moving another Nullable().
Declaration
public Nullable operator=(Nullable&& other) noexcept
Parameters
Nullable
other
|
Returns
Nullable
|
operator=(T&& value)
Reassigns the wrapped value by moving.
Declaration
public Nullable operator=(T&& value) noexcept
Parameters
T
value
|
Returns
Nullable
|
operator==(const Nullable& other)
Indicates whether this instance is equal to other one.
Declaration
public bool operator==(const Nullable& other) const
Parameters
Nullable
other
The other object. |
Returns
bool
|
Reset()
Disposes the wrapped value and sets the wrapped value to null. If the wrapped value is not valid, does nothing.
Declaration
public void Reset()
Returns
void
|
SetValue(const T& value)
Sets the wrapped value by copying.
Declaration
public void SetValue(const T& value)
Parameters
T
value
The value to be copied. |
Returns
void
|
Type Parameters
typename U
|
typename
|
SetValue(T&& value)
Sets the wrapped value by moving.
Declaration
public void SetValue(T&& value) noexcept
Parameters
T
value
The value to be moved. |
Returns
void
|
TrySet(const T& value)
If the wrapped value is not valid, sets it by copying. Otherwise, does nothing.
Declaration
public bool TrySet(const T& value)
Parameters
T
value
|
Returns
bool
True if the wrapped value was changed, otherwise false. |
Type Parameters
typename U
|
typename
|
TrySet(T&& value)
If the wrapped value is not valid, sets it by moving. Otherwise, does nothing.
Declaration
public bool TrySet(T&& value) noexcept
Parameters
T
value
|
Returns
bool
True if the wrapped value was changed, otherwise false. |