]>
Commit | Line | Data |
---|---|---|
f1717362 | 1 | // Copyright (C) 2014-2016 Free Software Foundation, Inc. |
a0d4f38d | 2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
18 | // { dg-options "-std=gnu++11" } | |
19 | // { dg-do compile } | |
20 | ||
21 | #include <queue> | |
22 | ||
c5dc0aa2 | 23 | using test_type = std::priority_queue<int>; |
24 | using container = test_type::container_type; | |
25 | using comp = std::less<container::value_type>; | |
26 | ||
a0d4f38d | 27 | template<typename A> |
c5dc0aa2 | 28 | using uses_allocator = std::uses_allocator<test_type, A>; |
29 | ||
30 | template<typename... Args> | |
31 | using is_constructible = std::is_constructible<test_type, Args...>; | |
32 | ||
33 | // test with invalid allocator | |
34 | using alloc_type = container::allocator_type; | |
a0d4f38d | 35 | |
c5dc0aa2 | 36 | static_assert( uses_allocator<alloc_type>::value, "valid allocator" ); |
a0d4f38d | 37 | |
c5dc0aa2 | 38 | static_assert( is_constructible<const alloc_type&>::value, |
39 | "priority_queue(const Alloc&)" ); | |
40 | static_assert( is_constructible<const comp&, const alloc_type&>::value, | |
41 | "priority_queue(const Cmp&, const Alloc&)" ); | |
42 | static_assert( is_constructible<const comp&, const container&, | |
43 | const alloc_type&>::value, | |
44 | "priority_queue(const Cmp&, const Container&, const Alloc&)" ); | |
45 | static_assert( is_constructible<const comp&, container&&, | |
46 | const alloc_type&>::value, | |
47 | "priority_queue(const Cmp&, const Container&, const Alloc&)" ); | |
48 | static_assert( is_constructible<const test_type&, const alloc_type&>::value, | |
49 | "priority_queue(const priority_queue&, const Alloc&)" ); | |
50 | static_assert( is_constructible<test_type&&, const alloc_type&>::value, | |
51 | "priority_queue(const priority_queue&, const Alloc&)" ); | |
52 | ||
53 | // test with invalid allocator | |
a0d4f38d | 54 | struct X { }; |
c5dc0aa2 | 55 | |
a0d4f38d | 56 | static_assert( !uses_allocator<X>::value, "invalid allocator" ); |
c5dc0aa2 | 57 | |
58 | static_assert( !is_constructible<const X&>::value, | |
59 | "priority_queue(const NonAlloc&)" ); | |
60 | static_assert( !is_constructible<const comp&, const X&>::value, | |
61 | "priority_queue(const Cmp&, const NonAlloc&)" ); | |
62 | static_assert( !is_constructible<const comp&, const container&, | |
63 | const X&>::value, | |
64 | "priority_queue(const Cmp&, const Cont&, const NonAlloc&)" ); | |
65 | static_assert( !is_constructible<const comp&, container&&, const X&>::value, | |
66 | "priority_queue(const Cmp&, const Cont&, const NonAlloc&)" ); | |
67 | static_assert( !is_constructible<const test_type&, const X&>::value, | |
68 | "priority_queue(const priority_queue&, const NonAlloc&)" ); | |
69 | static_assert( !is_constructible<test_type&&, const X&>::value, | |
70 | "priority_queue(const priority_queue&, const NonAlloc&)" ); |