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 // <queue> 11 12 // template <class Alloc> 13 // queue(const container_type& c, const Alloc& a); 14 15 #include <queue> 16 #include <cassert> 17 #include <cstddef> 18 19 #include "test_macros.h" 20 #include "test_allocator.h" 21 22 template <class C> 23 C 24 make(int n) 25 { 26 C c; 27 for (int i = 0; i < n; ++i) 28 c.push_back(i); 29 return c; 30 } 31 32 typedef std::deque<int, test_allocator<int> > C; 33 34 struct test 35 : public std::queue<int, C> 36 { 37 typedef std::queue<int, C> base; 38 39 explicit test(const test_allocator<int>& a) : base(a) {} 40 test(const container_type& c, const test_allocator<int>& a) : base(c, a) {} 41 #if TEST_STD_VER >= 11 42 test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {} 43 test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} 44 #endif 45 test_allocator<int> get_allocator() {return c.get_allocator();} 46 }; 47 48 int main() 49 { 50 C d = make<C>(5); 51 test q(d, test_allocator<int>(4)); 52 assert(q.get_allocator() == test_allocator<int>(4)); 53 assert(q.size() == 5); 54 for (C::size_type i = 0; i < d.size(); ++i) 55 { 56 assert(q.front() == d[i]); 57 q.pop(); 58 } 59 } 60