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// <stack>
11
12// template <class Alloc>
13//   stack(const stack& q, const Alloc& a);
14
15#include <stack>
16#include <cassert>
17
18#include "test_allocator.h"
19
20template <class C>
21C
22make(int n)
23{
24    C c;
25    for (int i = 0; i < n; ++i)
26        c.push_back(int(i));
27    return c;
28}
29
30typedef std::deque<int, test_allocator<int> > C;
31
32template <class T>
33struct test
34    : public std::stack<T, C>
35{
36    typedef std::stack<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
46int 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