Optional¶
-
template <typename T>
classOptional¶ This class encapsulates values which can be tested for null-ness.
Public Functions
-
Optional()¶ Constructor of an empty instance.
-
Optional(const T &value)¶ Constructor.
-
AMPL_EXPLICIT
operator bool() const¶ The cast to bool returns true if the instance has a value, false otherwise.
-
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.
-
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.
-
const T &
value() const¶ Accesses the contained value, returns a reference to the contained value.
- Exceptions
std::runtime_error: if the object does not contain a value
-