[libcxx-commits] [libcxx] [libc++] Reimplement `optional<T&>` as a partial specialization (PR #201983)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 9 02:11:44 PDT 2026


================
@@ -1254,60 +1149,48 @@ public:
   }
 
   template <class _Func>
-#      if _LIBCPP_STD_VER >= 26
-    requires(is_object_v<_Tp>)
-#      endif
   [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & {
     using _Up = remove_cv_t<invoke_result_t<_Func, _Tp&>>;
     static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
     static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t");
     static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(value()) should not be std::nullopt_t");
-    static_assert(is_object_v<_Up>, "Result of f(value()) should be an object type");
+    static_assert(__is_valid_optional_type<_Up>, "Result of f(value()) should be a valid contained type for optional");
----------------
philnik777 wrote:

Is this a bug fix? If so, please separate it from this patch.

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


More information about the libcxx-commits mailing list