1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <deque> 11 12 // deque& operator=(const deque& c); 13 14 #include <deque> 15 #include <cassert> 16 #include "test_allocator.h" 17 #include "min_allocator.h" 18 19 template <class C> 20 void 21 test(const C& x) 22 { 23 C c; 24 c = x; 25 assert(c == x); 26 } 27 28 int main() 29 { 30 { 31 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; 32 int* an = ab + sizeof(ab)/sizeof(ab[0]); 33 test(std::deque<int>(ab, an)); 34 } 35 { 36 std::deque<int, test_allocator<int> > l(3, 2, test_allocator<int>(5)); 37 std::deque<int, test_allocator<int> > l2(l, test_allocator<int>(3)); 38 l2 = l; 39 assert(l2 == l); 40 assert(l2.get_allocator() == test_allocator<int>(3)); 41 } 42 { 43 std::deque<int, other_allocator<int> > l(3, 2, other_allocator<int>(5)); 44 std::deque<int, other_allocator<int> > l2(l, other_allocator<int>(3)); 45 l2 = l; 46 assert(l2 == l); 47 assert(l2.get_allocator() == other_allocator<int>(5)); 48 } 49 #if __cplusplus >= 201103L 50 { 51 int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; 52 int* an = ab + sizeof(ab)/sizeof(ab[0]); 53 test(std::deque<int, min_allocator<int>>(ab, an)); 54 } 55 { 56 std::deque<int, min_allocator<int> > l(3, 2, min_allocator<int>()); 57 std::deque<int, min_allocator<int> > l2(l, min_allocator<int>()); 58 l2 = l; 59 assert(l2 == l); 60 assert(l2.get_allocator() == min_allocator<int>()); 61 } 62 #endif 63 } 64