[libcxx-commits] [libcxx] [libc++] Allow a disengaged `optional` to be `constexpr` since C++20 (PR #192888)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Apr 19 22:29:04 PDT 2026
================
@@ -402,6 +402,12 @@ struct __optional_destruct_base<_Tp, false> {
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept {
if (__engaged_) {
__val_.~value_type();
+ // TODO: Remove the workaround when supported compilers have CWG2424 implemented.
+# if _LIBCPP_STD_VER >= 20
+ if consteval {
----------------
eiytoq wrote:
Should we use `__libcpp_is_constant_evaluated()` instead of `if consteval` here, since `if consteval` is a C++23 extension?
```suggestion
if (__libcpp_is_constant_evaluated()) {
```
https://github.com/llvm/llvm-project/pull/192888
More information about the libcxx-commits
mailing list