13 #ifndef TestUtils_Option_HPP
14 #define TestUtils_Option_HPP
19 template <
typename T, T noValue = T()>
22 enum class State { VALUE, NO_VALUE };
25 explicit Option(T value) : state(State::VALUE), value(value) {}
26 Option() : state(State::NO_VALUE), value(noValue) {}
33 bool hasValue()
const {
return this->state == State::VALUE; }
35 this->state = State::VALUE;
38 void clear() { this->state = State::NO_VALUE; }
T getOrElse(T value) const
static Option< T > some(T value)
static constexpr Option< T > none()