cxx/test/containers/sequences/deque/deque.cons/move_assign.pass.cpp
Howard Hinnant 6046aced82 Fixing whitespace problems
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@111755 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-22 00:15:28 +00:00

73 lines
2.3 KiB
C++

//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <deque>
// deque& operator=(deque&& c);
#include <deque>
#include <cassert>
#include "../../../MoveOnly.h"
#include "../../../test_allocator.h"
int main()
{
#ifdef _LIBCPP_MOVE
{
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(5));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(5));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A(5));
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == A(5));
}
{
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(5));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(5));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A(6));
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() != 0);
assert(c3.get_allocator() == A(6));
}
{
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(5));
for (int* p = ab; p < an; ++p)
c1.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c2(A(5));
for (int* p = ab; p < an; ++p)
c2.push_back(MoveOnly(*p));
std::deque<MoveOnly, A> c3(A(6));
c3 = std::move(c1);
assert(c2 == c3);
assert(c1.size() == 0);
assert(c3.get_allocator() == A(5));
}
#endif // _LIBCPP_MOVE
}