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 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; 21 // 22 // protected: 23 // container_type c; 24 // ... 25 // }; 26 27 #include <stack> 28 #include <vector> 29 #include <type_traits> 30 31 struct test 32 : private std::stack<int> 33 { 34 test() 35 { 36 c.push_back(1); 37 } 38 }; 39 40 struct C 41 { 42 typedef int value_type; 43 typedef int& reference; 44 typedef const int& const_reference; 45 typedef int size_type; 46 }; 47 48 int main() 49 { 50 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), ""); 57 static_assert((!std::uses_allocator<std::stack<int, C>, std::allocator<int> >::value), ""); 58 test t; 59 } 60