• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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(const deque&);
13 
14 #include <deque>
15 #include <cassert>
16 #include "test_allocator.h"
17 #include "min_allocator.h"
18 
19 template <class C>
20 void
test(const C & x)21 test(const C& x)
22 {
23     C c(x);
24     assert(c == x);
25 }
26 
main()27 int main()
28 {
29     {
30         int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
31         int* an = ab + sizeof(ab)/sizeof(ab[0]);
32         test(std::deque<int>(ab, an));
33     }
34     {
35         std::deque<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
36         std::deque<int, test_allocator<int> > v2 = v;
37         assert(v2 == v);
38         assert(v2.get_allocator() == v.get_allocator());
39     }
40 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
41     {
42         std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
43         std::deque<int, other_allocator<int> > v2 = v;
44         assert(v2 == v);
45         assert(v2.get_allocator() == other_allocator<int>(-2));
46     }
47 #endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
48 #if __cplusplus >= 201103L
49     {
50         int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
51         int* an = ab + sizeof(ab)/sizeof(ab[0]);
52         test(std::deque<int, min_allocator<int>>(ab, an));
53     }
54     {
55         std::deque<int, min_allocator<int> > v(3, 2, min_allocator<int>());
56         std::deque<int, min_allocator<int> > v2 = v;
57         assert(v2 == v);
58         assert(v2.get_allocator() == v.get_allocator());
59     }
60 #endif
61 }
62