Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <queue> |
| 11 | |
| 12 | // template <class T, class Container = vector<T>, |
| 13 | // class Compare = less<typename Container::value_type>> |
| 14 | // class priority_queue |
| 15 | // { |
| 16 | // public: |
| 17 | // typedef Container container_type; |
| 18 | // typedef typename container_type::value_type value_type; |
| 19 | // typedef typename container_type::reference reference; |
| 20 | // typedef typename container_type::const_reference const_reference; |
| 21 | // typedef typename container_type::size_type size_type; |
Howard Hinnant | 6046ace | 2010-08-22 00:15:28 +0000 | [diff] [blame] | 22 | // |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 23 | // protected: |
| 24 | // container_type c; |
| 25 | // Compare comp; |
| 26 | |
| 27 | #include <queue> |
| 28 | #include <cassert> |
| 29 | #include <type_traits> |
| 30 | |
| 31 | struct test |
| 32 | : private std::priority_queue<int> |
| 33 | { |
| 34 | test() |
| 35 | { |
| 36 | c.push_back(1); |
| 37 | assert(comp(1, 2)); |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | struct C |
| 42 | { |
| 43 | typedef int value_type; |
| 44 | typedef int& reference; |
| 45 | typedef const int& const_reference; |
| 46 | typedef int size_type; |
| 47 | }; |
| 48 | |
| 49 | int main() |
| 50 | { |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 51 | static_assert((std::is_same<std::priority_queue<int>::container_type, std::vector<int> >::value), ""); |
| 52 | static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::container_type, std::deque<int> >::value), ""); |
| 53 | static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::value_type, int>::value), ""); |
| 54 | static_assert((std::is_same<std::priority_queue<int>::reference, std::vector<int>::reference>::value), ""); |
| 55 | static_assert((std::is_same<std::priority_queue<int>::const_reference, std::vector<int>::const_reference>::value), ""); |
| 56 | static_assert((std::is_same<std::priority_queue<int>::size_type, std::vector<int>::size_type>::value), ""); |
| 57 | static_assert((std::uses_allocator<std::priority_queue<int>, std::allocator<int> >::value), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 58 | static_assert((!std::uses_allocator<std::priority_queue<int, C>, std::allocator<int> >::value), ""); |
| 59 | test t; |
| 60 | } |