Optional

template<typename T>
class ampl::Optional

This class encapsulates values which can be tested for null-ness.

Public Functions

inline Optional()

Constructor of an empty instance.

inline Optional(const T &value)

Constructor.

inline explicit operator bool() const

The cast to bool returns true if the instance has a value, false otherwise.

inline const T &operator*() const

Accesses the contained value, returns a reference to the contained value.

The behaviour is undefined if the object does not contain a value.

inline const T *operator->() const

Accesses the contained value, returns a pointer to the contained value.

The behaviour is undefined if the object does not contain a value.

inline const T &value() const

Accesses the contained value, returns a reference to the contained value.

Throws

std::runtime_error – if the object does not contain a value