]> gcc.gnu.org Git - gcc.git/blame - libstdc++-v3/testsuite/23_containers/stack/requirements/uses_allocator.cc
Update copyright years.
[gcc.git] / libstdc++-v3 / testsuite / 23_containers / stack / requirements / uses_allocator.cc
CommitLineData
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
22using test_type = std::stack<int>;
23using container = test_type::container_type;
24
7666d649 25template<typename A>
997ed914
JW
26 using uses_allocator = std::uses_allocator<test_type, A>;
27
28template<typename... Args>
29 using is_constructible = std::is_constructible<test_type, Args...>;
30
31// test with valid allocator
32using alloc_type = container::allocator_type;
7666d649 33
997ed914 34static_assert( uses_allocator<alloc_type>::value, "valid allocator" );
7666d649 35
997ed914
JW
36static_assert( is_constructible<const alloc_type&>::value,
37 "stack(const Alloc&)" );
38static_assert( is_constructible<const container&, const alloc_type&>::value,
39 "stack(const container_type&, const Alloc&)" );
40static_assert( is_constructible<container&&, const alloc_type&>::value,
41 "stack(const container_type&, const Alloc&)" );
42static_assert( is_constructible<const test_type&, const alloc_type&>::value,
43 "stack(const stack&, const Alloc&)" );
44static_assert( is_constructible<test_type&&, const alloc_type&>::value,
45 "stack(const stack&, const Alloc&)" );
46
47// test with invalid allocator
7666d649 48struct X { };
997ed914 49
7666d649 50static_assert( !uses_allocator<X>::value, "invalid allocator" );
997ed914
JW
51
52static_assert( !is_constructible<const X&>::value,
53 "stack(const NonAlloc&)" );
54static_assert( !is_constructible<const container&, const X&>::value,
55 "stack(const container_type&, const NonAlloc&)" );
56static_assert( !is_constructible<container&&, const X&>::value,
57 "stack(const container_type&, const NonAlloc&)" );
58static_assert( !is_constructible<const test_type&, const X&>::value,
59 "stack(const stack&, const NonAlloc&)" );
60static_assert( !is_constructible<test_type&&, const X&>::value,
61 "stack(const stack&, const NonAlloc&)" );
This page took 0.545736 seconds and 5 git commands to generate.