Template Class Optional

Class Documentation

template<typename T>
class Optional

Simple DLL-safe container holding an optional object.

Simple optional type used to pass optional object across the DLL boundary.

Template Parameters

T – : Object type to store in the optional

Public Functions

inline Optional()

Constructs an optional with a null value.

inline Optional(T *InValue, std::function<void(T*)> InValueDestructor = DefaultDestructor<T>)

Constructs an optional with a given pointer.

Parameters
  • InValue – T* : Pointer to construct optional with

  • InValueDestructor – std::function<void(T*)> : Optional deleter to be called on destructer

inline Optional(std::nullptr_t InValue)

Constructs an optional with a null value.

Parameters

InValue – std::nullptr_t : nullptr value

template<typename U>
inline Optional(const U &InValue)

Constructs an optional by copying given value of a different type.

Parameters

InValue – const U& : Reference to construct optional with

inline Optional(const T &InValue)

Constructs an optional with a given reference.

Parameters

InValue – const T& : Reference to construct optional with

inline Optional(T &&InValue)

Constructs an optional with a given rvalue reference.

Parameters

InValue – T&& : Rvalue reference to construct optional with

inline Optional(const Optional<T> &Other)

Copy constructor.

Parameters

Other – const Optional<T>&

inline Optional(Optional<T> &&Other)

Move constructor.

Parameters

Other – Optional<T>&&

inline ~Optional()

Destructor.

inline bool HasValue() const

Checks of the options contains a value (non null).

Returns

bool

inline T *operator->() const

Accesses internal value by pointer.

Returns

T*

inline T &operator*() const

Accesses internal value by reference.

Returns

T&

inline Optional<T> &operator=(const T &InValue)

Assigns a value to the optional.

Parameters

Other – const T& : Reference to assign to optional

Returns

Optional<T>&

inline Optional<T> &operator=(const Optional<T> &Other)

Copy assignment.

Parameters

Other – const T& : Reference to assign to optional

Returns

Optional<T>&

inline Optional<T> &operator=(Optional<T> &&Other)

Move assignment.

Parameters

Other – const T& : Reference to assign to optional

Returns

Optional<T>&