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 queue& q, const Alloc& a); 14 15 #include <queue> 16 #include <cassert> 17 18 #include "test_allocator.h" 19 20 template <class C> 21 C 22 make(int n) 23 { 24 C c; 25 for (int i = 0; i < n; ++i) 26 c.push_back(i); 27 return c; 28 } 29 30 typedef std::deque<int, test_allocator<int> > C; 31 32 template <class T> 33 struct test 34 : public std::queue<T, C> 35 { 36 typedef std::queue<T, C> base; 37 typedef test_allocator<int> allocator_type; 38 typedef typename base::container_type container_type; 39 40 explicit test(const allocator_type& a) : base(a) {} 41 test(const container_type& c, const allocator_type& a) : base(c, a) {} 42 test(const test& q, const allocator_type& a) : base(q, a) {} 43 allocator_type get_allocator() {return this->c.get_allocator();} 44 }; 45 46 int main() 47 { 48 test<int> q(make<C>(5), test_allocator<int>(4)); 49 test<int> q2(q, test_allocator<int>(5)); 50 assert(q2.get_allocator() == test_allocator<int>(5)); 51 assert(q2.size() == 5); 52 } 53