[libcxx-commits] [libcxx] [libc++] Correct `optional<T&>` implementation (PR #174537)
William Tran-Viet via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jan 7 11:12:50 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_; }
----------------
smallp-o-p wrote:
Didn't want to ever potentially return a `T&&`, but I don't think that ever happened when testing. IMO it's clearer and simpler this way.
https://github.com/llvm/llvm-project/pull/174537
More information about the libcxx-commits
mailing list