[libcxx-commits] [libcxx] [libc++] Correct `optional<T&>` implementation (PR #174537)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jan 7 10:46:18 PST 2026


================
@@ -508,9 +508,7 @@ struct __optional_storage_base<_Tp, true> {
 
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return __value_ != nullptr; }
 
-  _LIBCPP_HIDE_FROM_ABI constexpr value_type& __get() const& noexcept { return *__value_; }
-
-  _LIBCPP_HIDE_FROM_ABI constexpr value_type&& __get() const&& noexcept { return std::forward<value_type>(*__value_); }
+  _LIBCPP_HIDE_FROM_ABI constexpr value_type& __get() const noexcept { return *__value_; }
----------------
frederick-vs-ja wrote:

If not necessary, I think we should revert changes to these lines.

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


More information about the libcxx-commits mailing list