[libcxx-commits] [libcxx] [libc++] Implement P2988R12: `std::optional<T&>` (PR #155202)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 23 06:10:38 PDT 2025


================
@@ -64,6 +64,12 @@ int main(int, char**)
         }
         assert(X::dtor_called == true);
     }
-
-  return 0;
+#if TEST_STD_VER >= 26
+    {
+      typedef int& T;
+      static_assert(std::is_trivially_destructible<T>::value, "");
+      static_assert(std::is_trivially_destructible<optional<T>>::value, "");
----------------
frederick-vs-ja wrote:

I'm inclined not to use pre-C++17 style.
```suggestion
      using T = int&;
      static_assert(std::is_trivially_destructible_v<T>);
      static_assert(std::is_trivially_destructible_v<optional<T>>);
```

Also, it seems better to test `X&` and lvalue reference to some function type.

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


More information about the libcxx-commits mailing list