[libcxx-commits] [libcxx] [libc++] Implement P2988R12: `std::optional<T&>` (PR #155202)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Nov 7 04:05:31 PST 2025
================
@@ -23,8 +23,7 @@ concept has_iterator_aliases = requires {
static_assert(has_iterator_aliases<std::optional<int>>);
static_assert(has_iterator_aliases<std::optional<const int>>);
-
-// TODO: Uncomment these once P2988R12 is implemented, as they would be testing optional<T&>
-
-// static_assert(!has_iterator_aliases<std::optional<int (&)[]>>);
-// static_assert(!has_iterator_aliases<std::optional<void (&)(int, char)>>);
+static_assert(has_iterator_aliases<std::optional<int&>>);
+static_assert(has_iterator_aliases<std::optional<const int&>>);
+static_assert(!has_iterator_aliases<std::optional<int (&)[1]>>);
----------------
frederick-vs-ja wrote:
Looks like that we should achieve the following results, per the current resolution of [LWG4308](https://cplusplus.github.io/LWG/issue4308).
```suggestion
static_assert(has_iterator_aliases<std::optional<int (&)[1]>>);
static_assert(!has_iterator_aliases<std::optional<int (&)[]>>);
```
The product code needs to be correspondingly adjusted. We can do this in a following-up PR as LWG4308 is not formally accepted yet (but it will be soon).
https://github.com/llvm/llvm-project/pull/155202
More information about the libcxx-commits
mailing list