]>
Commit | Line | Data |
---|---|---|
8d9254fc | 1 | // Copyright (C) 2014-2020 Free Software Foundation, Inc. |
7666d649 JW |
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 | ||
52066eae | 18 | // { dg-do compile { target c++11 } } |
7666d649 JW |
19 | |
20 | #include <stack> | |
21 | ||
997ed914 JW |
22 | using test_type = std::stack<int>; |
23 | using container = test_type::container_type; | |
24 | ||
7666d649 | 25 | template<typename A> |
997ed914 JW |
26 | using uses_allocator = std::uses_allocator<test_type, A>; |
27 | ||
28 | template<typename... Args> | |
29 | using is_constructible = std::is_constructible<test_type, Args...>; | |
30 | ||
31 | // test with valid allocator | |
32 | using alloc_type = container::allocator_type; | |
7666d649 | 33 | |
997ed914 | 34 | static_assert( uses_allocator<alloc_type>::value, "valid allocator" ); |
7666d649 | 35 | |
997ed914 JW |
36 | static_assert( is_constructible<const alloc_type&>::value, |
37 | "stack(const Alloc&)" ); | |
38 | static_assert( is_constructible<const container&, const alloc_type&>::value, | |
39 | "stack(const container_type&, const Alloc&)" ); | |
40 | static_assert( is_constructible<container&&, const alloc_type&>::value, | |
41 | "stack(const container_type&, const Alloc&)" ); | |
42 | static_assert( is_constructible<const test_type&, const alloc_type&>::value, | |
43 | "stack(const stack&, const Alloc&)" ); | |
44 | static_assert( is_constructible<test_type&&, const alloc_type&>::value, | |
45 | "stack(const stack&, const Alloc&)" ); | |
46 | ||
47 | // test with invalid allocator | |
7666d649 | 48 | struct X { }; |
997ed914 | 49 | |
7666d649 | 50 | static_assert( !uses_allocator<X>::value, "invalid allocator" ); |
997ed914 JW |
51 | |
52 | static_assert( !is_constructible<const X&>::value, | |
53 | "stack(const NonAlloc&)" ); | |
54 | static_assert( !is_constructible<const container&, const X&>::value, | |
55 | "stack(const container_type&, const NonAlloc&)" ); | |
56 | static_assert( !is_constructible<container&&, const X&>::value, | |
57 | "stack(const container_type&, const NonAlloc&)" ); | |
58 | static_assert( !is_constructible<const test_type&, const X&>::value, | |
59 | "stack(const stack&, const NonAlloc&)" ); | |
60 | static_assert( !is_constructible<test_type&&, const X&>::value, | |
61 | "stack(const stack&, const NonAlloc&)" ); |