+2017-04-04 Pedro Alves <palves@redhat.com>
+
+ * common/gdb_optional.h (gdb::optiona): Add operator->, operator*,
+ operator bool, has_value and get methods.
+
2017-04-04 Pedro Alves <palves@redhat.com>
* dwarf2read.c (struct file_entry): Add ctors, and initialize all
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. */
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
{