2010-05-11 21:42:16 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2010-05-11 23:36:01 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
2010-11-16 23:09:02 +01:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-05-11 21:42:16 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <deque>
|
|
|
|
|
|
|
|
// deque(deque&& c, const allocator_type& a);
|
|
|
|
|
|
|
|
#include <deque>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
#include "../../../MoveOnly.h"
|
|
|
|
#include "../../../test_allocator.h"
|
2013-06-23 23:17:24 +02:00
|
|
|
#include "../../../min_allocator.h"
|
2010-05-11 21:42:16 +02:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
2010-09-05 01:28:19 +02:00
|
|
|
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
2010-05-11 21:42:16 +02:00
|
|
|
{
|
|
|
|
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(1));
|
|
|
|
for (int* p = ab; p < an; ++p)
|
|
|
|
c2.push_back(MoveOnly(*p));
|
|
|
|
std::deque<MoveOnly, A> c3(std::move(c1), A(3));
|
|
|
|
assert(c2 == c3);
|
|
|
|
assert(c3.get_allocator() == A(3));
|
|
|
|
assert(c1.size() != 0);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
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(1));
|
|
|
|
for (int* p = ab; p < an; ++p)
|
|
|
|
c2.push_back(MoveOnly(*p));
|
|
|
|
std::deque<MoveOnly, A> c3(std::move(c1), A(1));
|
|
|
|
assert(c2 == c3);
|
|
|
|
assert(c3.get_allocator() == A(1));
|
|
|
|
assert(c1.size() == 0);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
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(1));
|
|
|
|
for (int* p = ab; p < an; ++p)
|
|
|
|
c2.push_back(MoveOnly(*p));
|
|
|
|
std::deque<MoveOnly, A> c3(std::move(c1), A(3));
|
|
|
|
assert(c2 == c3);
|
|
|
|
assert(c3.get_allocator() == A(3));
|
|
|
|
assert(c1.size() != 0);
|
|
|
|
}
|
2013-06-23 23:17:24 +02:00
|
|
|
#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), A());
|
|
|
|
assert(c2 == c3);
|
|
|
|
assert(c3.get_allocator() == A());
|
|
|
|
assert(c1.size() == 0);
|
|
|
|
}
|
|
|
|
#endif
|
2010-09-05 01:28:19 +02:00
|
|
|
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
2010-05-11 21:42:16 +02:00
|
|
|
}
|