blob: 951160dd8a1ad795560f7e0f9fadca1a7d7c8782 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
5// This file is distributed under the University of Illinois Open Source
6// License. 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
18#include "../../../../test_allocator.h"
19#include "../../../../MoveOnly.h"
20
Howard Hinnant73d21a42010-09-04 23:28:19 +000021#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022
23template <class C>
24C
25make(int n)
26{
27 C c;
28 for (int i = 0; i < n; ++i)
29 c.push_back(MoveOnly(i));
30 return c;
31}
32
33typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
34
35template <class T>
36struct test
37 : public std::queue<T, C>
38{
39 typedef std::queue<T, C> base;
40 typedef test_allocator<MoveOnly> allocator_type;
41 typedef typename base::container_type container_type;
42
43 explicit test(const allocator_type& a) : base(a) {}
44 test(const container_type& c, const allocator_type& a) : base(c, a) {}
45 test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
46 test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
47 allocator_type get_allocator() {return this->c.get_allocator();}
48};
49
Howard Hinnant73d21a42010-09-04 23:28:19 +000050#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000051
52int main()
53{
Howard Hinnant73d21a42010-09-04 23:28:19 +000054#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000055 test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
56 assert(q.get_allocator() == test_allocator<MoveOnly>(4));
57 assert(q.size() == 5);
Howard Hinnant73d21a42010-09-04 23:28:19 +000058#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000059}