[libcxx-commits] [libcxx] [libc++] Improve the test coverage for std::vector::emplace (PR #132440)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Mar 22 06:30:06 PDT 2025
================
@@ -38,7 +38,35 @@ struct Throws {
};
bool Throws::sThrows = false;
-#endif
+
+struct ThrowingMove {
+ TEST_CONSTEXPR ThrowingMove() : value(0), do_throw(false) {}
+ TEST_CONSTEXPR explicit ThrowingMove(int v) : value(v), do_throw(false) {}
+ TEST_CONSTEXPR explicit ThrowingMove(int v, bool do_throw) : value(v), do_throw(do_throw) {}
+
+ ThrowingMove(const ThrowingMove& rhs) = default;
+ ThrowingMove& operator=(const ThrowingMove&) = default;
+
+ TEST_CONSTEXPR_CXX14 ThrowingMove(ThrowingMove&& rhs) : value(rhs.value), do_throw(rhs.do_throw) {
+ if (do_throw)
+ throw 1;
+ }
+ TEST_CONSTEXPR_CXX14 ThrowingMove& operator=(ThrowingMove&& rhs) {
+ value = rhs.value;
+ do_throw = rhs.do_throw;
+ if (do_throw)
+ throw 1;
+ return *this;
+ }
----------------
winner245 wrote:
I think you are right. I've tested on experimental mode with [P3068](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3068r4.html) enabled ([Godbolt link](https://godbolt.org/z/YhEEfc4Wv)). My test suggests that using `TEST_CONSTEXPR_CXX14` should be fine if constexpr throwing is supported in C++26, and we may fail expectedly without P3068 support.
https://github.com/llvm/llvm-project/pull/132440
More information about the libcxx-commits
mailing list