template<typename T>
class shogun::Maybe< T >
Holder that represents an object that can be either present or absent. Quite simllar to std::optional introduced in C++14, but provides a way to pass the reason of absence (e.g. "incorrect parameter").
Essentially, instances are created via
- See also
- Just or
-
Nothing
Maybe<int> absent_value = Nothing();
Maybe<int> present_value =
Just(3);
To check whether value is present, regular implicit cast to bool is used:
if (maybe_value)
{
}
else
{
}
To obtain value,
- See also
- value is used:
int value = unreliable.value();
To provide default values,
- See also
- value_or is used:
int value = unreliable.value_or(9);
Definition at line 86 of file maybe.h.