[libcxx-commits] [libcxx] [libc++] Strengthen optional value constructor noexcept (PR #202765)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 15 12:51:47 PDT 2026


================
@@ -139,6 +152,14 @@ void test_explicit() {
     }
     assert(T::alive == 0);
   }
+  {
+    LIBCPP_ASSERT_NOEXCEPT(optional<ExplicitNoThrow>(42));
+    LIBCPP_ASSERT_NOT_NOEXCEPT(optional<ExplicitThrow>(42));
+  }
+  {
+    LIBCPP_ASSERT_NOEXCEPT(optional<std::vector<int>>(std::declval<std::vector<int>&&>()));
+    LIBCPP_STATIC_ASSERT(std::is_nothrow_constructible<optional<std::vector<int>>, std::vector<int>&&>::value, "");
----------------
ldionne wrote:

Aren't those two things equivalent by definition? I'd suggest dropping one of them -- probably the first one.

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


More information about the libcxx-commits mailing list