template struct Optional (Niantic.ARDK.Utilities.Optional)

Overview

A value that may not exist. More…

template <T>
struct Optional:
    IEquatable< Optional< T >>,
    IEquatable< T > {
    // properties

    bool HasValue;
    T Value;

    // methods

    void Clear();
    override bool Equals(object obj);
    bool Equals(Optional<T> other);
    bool Equals(T other);
    override int GetHashCode();
    T GetOrDefault();
    Optional(T value);
    static implicit operator Optional< T > (T value);
    static static operator T (Optional<T> optional);
    static bool operator != (Optional<T> a, Optional<T> b);
    static bool operator != (Optional<T> a, T b);
    static bool operator != (T a, Optional<T> b);
    static bool operator == (Optional<T> a, Optional<T> b);
    static bool operator == (Optional<T> a, T b);
    static bool operator == (T a, Optional<T> b);
};

Detailed Documentation

A value that may not exist.

Optional provides implicit conversion between itself and

T

and explicit for the opposite.

Parameters:

T

Properties

bool HasValue

True when a value does exist.

T Value

Gets or sets the value.

Parameters:

NullReferenceException

If getting the value and there is no value.

Methods

void Clear()

Clears the value.

bool Equals(Optional<T> other)

Checks the equality between two Optionals

Parameters:

other

Returns:

bool Equals(T other)

Checks the equality between and Optional<T> and T

Parameters:

other

Returns:

T GetOrDefault()

Returns the value of the optional, or the default of T if no value has been set

Returns:

Optional(T value)

Creates a new optional with a given default value.

Parameters:

value