]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/23_containers/stack/requirements/uses_allocator.cc
1 // Copyright (C) 2014-2015 Free Software Foundation, Inc.
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)
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.
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/>.
18 // { dg-options "-std=gnu++11" }
23 using test_type
= std::stack
<int>;
24 using container
= test_type::container_type
;
27 using uses_allocator
= std::uses_allocator
<test_type
, A
>;
29 template<typename
... Args
>
30 using is_constructible
= std::is_constructible
<test_type
, Args
...>;
32 // test with valid allocator
33 using alloc_type
= container::allocator_type
;
35 static_assert( uses_allocator
<alloc_type
>::value
, "valid allocator" );
37 static_assert( is_constructible
<const alloc_type
&>::value
,
38 "stack(const Alloc&)" );
39 static_assert( is_constructible
<const container
&, const alloc_type
&>::value
,
40 "stack(const container_type&, const Alloc&)" );
41 static_assert( is_constructible
<container
&&, const alloc_type
&>::value
,
42 "stack(const container_type&, const Alloc&)" );
43 static_assert( is_constructible
<const test_type
&, const alloc_type
&>::value
,
44 "stack(const stack&, const Alloc&)" );
45 static_assert( is_constructible
<test_type
&&, const alloc_type
&>::value
,
46 "stack(const stack&, const Alloc&)" );
48 // test with invalid allocator
51 static_assert( !uses_allocator
<X
>::value
, "invalid allocator" );
53 static_assert( !is_constructible
<const X
&>::value
,
54 "stack(const NonAlloc&)" );
55 static_assert( !is_constructible
<const container
&, const X
&>::value
,
56 "stack(const container_type&, const NonAlloc&)" );
57 static_assert( !is_constructible
<container
&&, const X
&>::value
,
58 "stack(const container_type&, const NonAlloc&)" );
59 static_assert( !is_constructible
<const test_type
&, const X
&>::value
,
60 "stack(const stack&, const NonAlloc&)" );
61 static_assert( !is_constructible
<test_type
&&, const X
&>::value
,
62 "stack(const stack&, const NonAlloc&)" );