diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/common.h b/libcxx/test/std/containers/sequences/vector/vector.modifiers/common.h index 72cd47a50b2c..f0e5d9df29f3 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/common.h +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/common.h @@ -38,7 +38,35 @@ struct Throws { }; bool Throws::sThrows = false; -#endif + +struct ThrowingMoveOnly { + TEST_CONSTEXPR ThrowingMoveOnly() : value(0), do_throw(false) {} + TEST_CONSTEXPR explicit ThrowingMoveOnly(int v) : value(v), do_throw(false) {} + TEST_CONSTEXPR explicit ThrowingMoveOnly(int v, bool throw_) : value(v), do_throw(throw_) {} + + ThrowingMoveOnly(const ThrowingMoveOnly& rhs) = delete; + ThrowingMoveOnly& operator=(const ThrowingMoveOnly&) = delete; + + TEST_CONSTEXPR_CXX14 ThrowingMoveOnly(ThrowingMoveOnly&& rhs) : value(rhs.value), do_throw(rhs.do_throw) { + if (do_throw) + throw 1; + } + TEST_CONSTEXPR_CXX14 ThrowingMoveOnly& operator=(ThrowingMoveOnly&& rhs) { + value = rhs.value; + do_throw = rhs.do_throw; + if (do_throw) + throw 1; + return *this; + } + + TEST_CONSTEXPR_CXX14 friend bool operator==(ThrowingMoveOnly const& lhs, ThrowingMoveOnly const& rhs) { + return lhs.value == rhs.value; + } + + int value; + bool do_throw; +}; +#endif // TEST_HAS_NO_EXCEPTIONS struct Tracker { int copy_assignments = 0; diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp index 667ce483806e..25e78f5f2b74 100644 --- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp @@ -7,150 +7,329 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03 && !stdlib=libc++ +// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=9000000 // // template iterator emplace(const_iterator pos, Args&&... args); -#include #include +#include +#include +#include +#include -#include "test_macros.h" -#include "test_allocator.h" -#include "min_allocator.h" #include "asan_testing.h" +#include "common.h" +#include "min_allocator.h" +#include "MoveOnly.h" +#include "test_allocator.h" +#include "test_macros.h" -class A { - int i_; - double d_; +template +struct has_moved_from_sentinel_value : std::false_type {}; - A(const A&); - A& operator=(const A&); +template <> +struct has_moved_from_sentinel_value : std::true_type {}; -public: - TEST_CONSTEXPR_CXX14 A(int i, double d) : i_(i), d_(d) {} +template