summaryrefslogtreecommitdiff
path: root/test/std/containers/sequences/deque/deque.cons/move.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/containers/sequences/deque/deque.cons/move.pass.cpp')
-rw-r--r--test/std/containers/sequences/deque/deque.cons/move.pass.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/std/containers/sequences/deque/deque.cons/move.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move.pass.cpp
new file mode 100644
index 0000000000000..4a7aa8a058eba
--- /dev/null
+++ b/test/std/containers/sequences/deque/deque.cons/move.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&&);
+
+#include <deque>
+#include <cassert>
+
+#include "MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(2));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == c1.get_allocator());
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef other_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(2));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == c1.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef min_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A{});
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A{});
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == c1.get_allocator());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}