aboutsummaryrefslogtreecommitdiff
path: root/gdb/common/gdb_optional.h
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/common/gdb_optional.h')
-rw-r--r--gdb/common/gdb_optional.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/gdb/common/gdb_optional.h b/gdb/common/gdb_optional.h
index d991da1..fef7a73 100644
--- a/gdb/common/gdb_optional.h
+++ b/gdb/common/gdb_optional.h
@@ -61,6 +61,31 @@ public:
m_instantiated = true;
}
+ /* Observers. */
+ constexpr const T *operator-> () const
+ { return std::addressof (this->get ()); }
+
+ T *operator-> ()
+ { return std::addressof (this->get ()); }
+
+ constexpr const T &operator* () const &
+ { return this->get (); }
+
+ T &operator* () &
+ { return this->get (); }
+
+ T &&operator* () &&
+ { return std::move (this->get ()); }
+
+ constexpr const T &&operator* () const &&
+ { return std::move (this->get ()); }
+
+ constexpr explicit operator bool () const noexcept
+ { return m_instantiated; }
+
+ constexpr bool has_value () const noexcept
+ { return m_instantiated; }
+
private:
/* Destroy the object. */
@@ -71,6 +96,10 @@ private:
m_item.~T ();
}
+ /* The get operations have m_instantiated as a precondition. */
+ T &get () noexcept { return m_item; }
+ constexpr const T &get () const noexcept { return m_item; }
+
/* The object. */
union
{