[libcxx-commits] [libcxx] [libc++] Collapse `optional<T&>` inheritance hierarchy (PR #215286)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Aug 11 02:10:54 PDT 2026


================
@@ -235,7 +190,7 @@ class optional<_Tp&> : public __optional_ref_iterator_base<_Tp&> {
 
   constexpr ~optional() = default;
 
-  using __base::__get;
+  _LIBCPP_HIDE_FROM_ABI constexpr value_type& __get() const noexcept { return *__value_; }
----------------
philnik777 wrote:

AFAICT the only places where this is relevant are `__construct_from` and `__assign_from`, and in those places we already check `has_value()`, so the compiler should be perfectly capable of optimizing the check away. I don't think we need to do that manually.

https://github.com/llvm/llvm-project/pull/215286


More information about the libcxx-commits mailing list