[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


================
@@ -33,6 +33,13 @@ int main(int, char**)
         constexpr optional<int> opt(0);
         static_assert(opt.has_value(), "");
     }
+#if TEST_STD_VER >= 26
+    {
+      static constexpr int i = 0;
+      constexpr optional<const int&> opt{i};
+      static_assert(opt.has_value(), "");
----------------
frederick-vs-ja wrote:

```suggestion
      static_assert(opt.has_value());
```
(Ditto other `static_assert(COND, "");` -> `static_asset(COND);`.

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


More information about the libcxx-commits mailing list