]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/stack/requirements/uses_allocator.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / stack / requirements / uses_allocator.cc
CommitLineData
fbd26352 1// Copyright (C) 2014-2019 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
be58e01d 18// { dg-do compile { target c++11 } }
a0d4f38d 19
20#include <stack>
21
c5dc0aa2 22using test_type = std::stack<int>;
23using container = test_type::container_type;
24
a0d4f38d 25template<typename A>
c5dc0aa2 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;
a0d4f38d 33
c5dc0aa2 34static_assert( uses_allocator<alloc_type>::value, "valid allocator" );
a0d4f38d 35
c5dc0aa2 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
a0d4f38d 48struct X { };
c5dc0aa2 49
a0d4f38d 50static_assert( !uses_allocator<X>::value, "invalid allocator" );
c5dc0aa2 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&)" );