]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/priority_queue/requirements/uses_allocator.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / priority_queue / requirements / uses_allocator.cc
CommitLineData
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 23using test_type = std::priority_queue<int>;
24using container = test_type::container_type;
25using comp = std::less<container::value_type>;
26
a0d4f38d 27template<typename A>
c5dc0aa2 28 using uses_allocator = std::uses_allocator<test_type, A>;
29
30template<typename... Args>
31 using is_constructible = std::is_constructible<test_type, Args...>;
32
33// test with invalid allocator
34using alloc_type = container::allocator_type;
a0d4f38d 35
c5dc0aa2 36static_assert( uses_allocator<alloc_type>::value, "valid allocator" );
a0d4f38d 37
c5dc0aa2 38static_assert( is_constructible<const alloc_type&>::value,
39 "priority_queue(const Alloc&)" );
40static_assert( is_constructible<const comp&, const alloc_type&>::value,
41 "priority_queue(const Cmp&, const Alloc&)" );
42static_assert( is_constructible<const comp&, const container&,
43 const alloc_type&>::value,
44 "priority_queue(const Cmp&, const Container&, const Alloc&)" );
45static_assert( is_constructible<const comp&, container&&,
46 const alloc_type&>::value,
47 "priority_queue(const Cmp&, const Container&, const Alloc&)" );
48static_assert( is_constructible<const test_type&, const alloc_type&>::value,
49 "priority_queue(const priority_queue&, const Alloc&)" );
50static_assert( is_constructible<test_type&&, const alloc_type&>::value,
51 "priority_queue(const priority_queue&, const Alloc&)" );
52
53// test with invalid allocator
a0d4f38d 54struct X { };
c5dc0aa2 55
a0d4f38d 56static_assert( !uses_allocator<X>::value, "invalid allocator" );
c5dc0aa2 57
58static_assert( !is_constructible<const X&>::value,
59 "priority_queue(const NonAlloc&)" );
60static_assert( !is_constructible<const comp&, const X&>::value,
61 "priority_queue(const Cmp&, const NonAlloc&)" );
62static_assert( !is_constructible<const comp&, const container&,
63 const X&>::value,
64 "priority_queue(const Cmp&, const Cont&, const NonAlloc&)" );
65static_assert( !is_constructible<const comp&, container&&, const X&>::value,
66 "priority_queue(const Cmp&, const Cont&, const NonAlloc&)" );
67static_assert( !is_constructible<const test_type&, const X&>::value,
68 "priority_queue(const priority_queue&, const NonAlloc&)" );
69static_assert( !is_constructible<test_type&&, const X&>::value,
70 "priority_queue(const priority_queue&, const NonAlloc&)" );