24 using nonConstT =
typename std::remove_const<T>::type;
34 bool has_value()
const {
return _ptr !=
nullptr; }
38 throw std::bad_optional_access();
43 T& value_or(T& default_)
const {
return _ptr ? *_ptr : default_; }
44 void reset() { _ptr =
nullptr; }
46 T* operator->()
const {
return _ptr; }
47 T& operator*()
const {
return *_ptr; }
64 explicit operator bool()
const {
return _ptr; }
67 if ( has_value() && other.has_value() )
68 return value() == other.value();
70 return ! (has_value() || other.has_value());
73 bool operator!=(
const optional_ref<T>& other)
const {
return ! (*
this == other); }
75 operator std::optional<nonConstT>()
const {
Definition: optional-ref.h:22