summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2015-01-28 19:54:25 +0000
committerMarshall Clow <mclow.lists@gmail.com>2015-01-28 19:54:25 +0000
commitd5f461ca03e3028b1202c0c4c75d9480b3219551 (patch)
tree2168eb257f5ad3b0d19402c72a8f60ca83cae82d /libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
parente6972a029f5d173cdd29b7167c8f4a1901238e0b (diff)
downloadbcm5719-llvm-d5f461ca03e3028b1202c0c4c75d9480b3219551.tar.gz
bcm5719-llvm-d5f461ca03e3028b1202c0c4c75d9480b3219551.zip
Fix PR22366. When move-constructing an associative container and explicitly passing an allocator that compares different, we were not calling the destructor of the elements in the moved-from container.
llvm-svn: 227359
Diffstat (limited to 'libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp')
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
index c4617f0b481..bad5e8f8c9e 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
@@ -19,6 +19,7 @@
#include "../../../MoveOnly.h"
#include "../../../test_compare.h"
#include "test_allocator.h"
+#include "Counter.h"
int main()
{
@@ -137,5 +138,51 @@ int main()
assert(m3.key_comp() == C(5));
assert(m1.empty());
}
+ {
+ typedef Counter<int> V;
+ typedef std::less<V> C;
+ typedef test_allocator<V> A;
+ typedef std::set<V, C, A> M;
+ typedef V* I;
+ Counter_base::gConstructed = 0;
+ {
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ const size_t num = sizeof(a1)/sizeof(a1[0]);
+ assert(Counter_base::gConstructed == num);
+
+ M m1(I(a1), I(a1+num), C(), A());
+ assert(Counter_base::gConstructed == 3+num);
+
+ M m2(m1);
+ assert(m2 == m1);
+ assert(Counter_base::gConstructed == 6+num);
+
+ M m3(std::move(m1), A());
+ assert(m3 == m2);
+ assert(m1.empty());
+ assert(Counter_base::gConstructed == 6+num);
+
+ {
+ M m4(std::move(m2), A(5));
+ assert(Counter_base::gConstructed == 6+num);
+ assert(m4 == m3);
+ assert(m2.empty());
+ }
+ assert(Counter_base::gConstructed == 3+num);
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
OpenPOWER on IntegriCloud