blob: afc5ebd5375386a1b61f919fa2194389c0a43faa [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//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <stack>
11
12// template <class T, class Container = deque<T>>
13// class stack
14// {
15// public:
16// typedef Container container_type;
17// typedef typename container_type::value_type value_type;
18// typedef typename container_type::reference reference;
19// typedef typename container_type::const_reference const_reference;
20// typedef typename container_type::size_type size_type;
Howard Hinnant6046ace2010-08-22 00:15:28 +000021//
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022// protected:
23// container_type c;
24// ...
25// };
26
27#include <stack>
28#include <vector>
29#include <type_traits>
30
31struct test
32 : private std::stack<int>
33{
34 test()
35 {
36 c.push_back(1);
37 }
38};
39
40struct C
41{
42 typedef int value_type;
43 typedef int& reference;
44 typedef const int& const_reference;
45 typedef int size_type;
46};
47
48int main()
49{
Dan Albert1d4a1ed2016-05-25 22:36:09 -070050 static_assert((std::is_same<std::stack<int>::container_type, std::deque<int> >::value), "");
51 static_assert((std::is_same<std::stack<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
52 static_assert((std::is_same<std::stack<double, std::vector<int> >::value_type, int>::value), "");
53 static_assert((std::is_same<std::stack<int>::reference, std::deque<int>::reference>::value), "");
54 static_assert((std::is_same<std::stack<int>::const_reference, std::deque<int>::const_reference>::value), "");
55 static_assert((std::is_same<std::stack<int>::size_type, std::deque<int>::size_type>::value), "");
56 static_assert((std::uses_allocator<std::stack<int>, std::allocator<int> >::value), "");
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000057 static_assert((!std::uses_allocator<std::stack<int, C>, std::allocator<int> >::value), "");
58 test t;
59}