]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/scoped_allocator/3.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / scoped_allocator / 3.cc
CommitLineData
8d9254fc 1// Copyright (C) 2016-2020 Free Software Foundation, Inc.
937ec71a
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
18// { dg-do compile { target c++11 } }
19
20#include <scoped_allocator>
21#include <testsuite_allocator.h>
22
23template<typename T>
24struct alloc
25{
26 using value_type = T;
27 alloc() = default;
28 template<typename U>
29 alloc(alloc<U>) { }
30 T* allocate(std::size_t);
31 void deallocate(T*, std::size_t);
32};
33
34template<typename T, typename U>
35 bool operator==(alloc<T>, alloc<U>) { return true; }
36
37template<typename T, typename U>
38 bool operator!=(alloc<T>, alloc<U>) { return false; }
39
40using scoped = std::scoped_allocator_adaptor<alloc<int>>;
41using other_alloc = __gnu_test::SimpleAllocator<int>;
42using other_scoped = std::scoped_allocator_adaptor<other_alloc>;
43
44using std::is_constructible;
45
46static_assert( is_constructible<scoped, const scoped&>::value,
47 "is_constructible<scoped, const scoped&>");
48static_assert( is_constructible<scoped, scoped>::value,
49 "is_constructible<scoped, scoped>");
50static_assert( is_constructible<scoped, const alloc<int>&>::value,
51 "is_constructible<scoped, const outer_allocator_type&>");
52static_assert( is_constructible<scoped, alloc<int>>::value,
53 "is_constructible<scoped, outer_allocator_type>");
54static_assert( is_constructible<scoped, const alloc<long>&>::value,
55 "is_constructible<scoped, const outer_allocator_type::rebind<U>::type&>");
56static_assert( is_constructible<scoped, alloc<long>>::value,
57 "is_constructible<scoped, outer_allocator_type::rebind<U>::type>");
58
59static_assert( !is_constructible<scoped, const other_alloc&>::value,
60 "!is_constructible<scoped, const other_alloc&>");
61static_assert( !is_constructible<scoped, other_alloc>::value,
62 "!is_constructible<scoped, other_alloc>");
63static_assert( !is_constructible<scoped, const other_scoped&>::value,
64 "!is_constructible<scoped, const other_scoped&>");
65static_assert( !is_constructible<scoped, other_scoped>::value,
66 "!is_constructible<scoped, other_scoped>");