[libc-commits] [compiler-rt] [flang] [llvm] [libcxx] [clang-tools-extra] [libc] [clang] [libc++] Implement LWG3940: std::expected<void, E>::value() also needs E to be copy constructible (PR #71819)

Mark de Wever via libc-commits libc-commits at lists.llvm.org
Sun Jan 7 09:05:33 PST 2024


================
@@ -1150,12 +1150,15 @@ class expected<_Tp, _Err> {
   }
 
   _LIBCPP_HIDE_FROM_ABI constexpr void value() const& {
+    static_assert(is_copy_constructible_v<_Err>);
     if (!__has_val_) {
       std::__throw_bad_expected_access<_Err>(__union_.__unex_);
     }
   }
 
   _LIBCPP_HIDE_FROM_ABI constexpr void value() && {
+    static_assert(is_copy_constructible_v<_Err> && is_move_constructible_v<_Err>,
+                  "error_type has to be both copy constructible and move constructible");
----------------
mordante wrote:

Since we don't require a message in `static_assert` anymore and this message adds no extra information, let's remove it.

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


More information about the libc-commits mailing list