[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
Fri Mar 21 13:55:57 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:
```suggestion
TEST_CONSTEXPR_CXX26 ThrowingMove& operator=(ThrowingMove&& rhs) {
value = rhs.value;
do_throw = rhs.do_throw;
if (do_throw)
throw 1;
return *this;
}
```
I don't think `throw` is supported by C++14 constexpr. I am not sure clang currently supports `throw` or not. But at least, we need to use `TEST_CONSTEXPR_CXX26`.
https://github.com/llvm/llvm-project/pull/132440
More information about the libcxx-commits
mailing list