]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/unique_ptr/cons/lwg2905.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / unique_ptr / cons / lwg2905.cc
CommitLineData
a945c346 1// Copyright (C) 2017-2024 Free Software Foundation, Inc.
86fc6ec9
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 <memory>
21
22template<typename T, typename D, typename P, typename E>
23constexpr bool check()
24{ return std::is_constructible<std::unique_ptr<T, D>, P, E>::value; }
25
26struct Del { void operator()(void*) const { } };
27
28static_assert( ! check<int, Del&, int*, Del>(), "" );
29static_assert( check<int, Del&, int*, Del&>(), "" );
30static_assert( check<int, const Del&, int*, Del&>(), "" );
31static_assert( ! check<int, Del&, int*, const Del&>(), "" );
32static_assert( check<int, Del, int*, const Del&>(), "" );
33static_assert( check<int, Del, int*, Del>(), "" );
34
35static_assert( ! check<int[], Del&, int*, Del>(), "" );
36static_assert( check<int[], Del&, int*, Del&>(), "" );
37static_assert( check<int[], const Del&, int*, Del&>(), "" );
38static_assert( ! check<int[], Del&, int*, const Del&>(), "" );
39static_assert( check<int[], Del, int*, const Del&>(), "" );
40static_assert( check<int[], Del, int*, Del>(), "" );
41
42struct DelNoCopy {
43 DelNoCopy() = default;
44 DelNoCopy(const DelNoCopy&) = delete;
45 DelNoCopy(DelNoCopy&&) = default;
46 void operator()(void*) const { }
47};
48
49static_assert( ! check<int, DelNoCopy&, int*, DelNoCopy>(), "" );
50static_assert( check<int, DelNoCopy&, int*, DelNoCopy&>(), "" );
51static_assert( check<int, const DelNoCopy&, int*, DelNoCopy&>(), "" );
52static_assert( ! check<int, DelNoCopy&, int*, const DelNoCopy&>(), "" );
53static_assert( ! check<int, DelNoCopy, int*, const DelNoCopy&>(), "" );
54static_assert( check<int, DelNoCopy, int*, DelNoCopy>(), "" );
55
56static_assert( ! check<int[], DelNoCopy&, int*, DelNoCopy>(), "" );
57static_assert( check<int[], DelNoCopy&, int*, DelNoCopy&>(), "" );
58static_assert( check<int[], const DelNoCopy&, int*, DelNoCopy&>(), "" );
59static_assert( ! check<int[], DelNoCopy&, int*, const DelNoCopy&>(), "" );
60static_assert( ! check<int[], DelNoCopy, int*, const DelNoCopy&>(), "" );
61static_assert( check<int[], DelNoCopy, int*, DelNoCopy>(), "" );
62
63struct Base { virtual ~Base() { } };
64struct Derived : Base { };
65
66static_assert( ! check<Base[], Del&, Base*, Del>(), "" );
67static_assert( check<Base[], Del&, Base*, Del&>(), "" );
68static_assert( check<Base[], const Del&, Base*, Del&>(), "" );
69static_assert( ! check<Base[], Del&, Base*, const Del&>(), "" );
70static_assert( check<Base[], Del, Base*, const Del&>(), "" );
71static_assert( check<Base[], Del, Base*, Del>(), "" );
72
73static_assert( ! check<Base[], Del&, Derived*, Del>(), "" );
74static_assert( ! check<Base[], Del&, Derived*, Del&>(), "" );
75static_assert( ! check<Base[], const Del&, Derived*, Del&>(), "" );
76static_assert( ! check<Base[], Del&, Derived*, const Del&>(), "" );
77static_assert( ! check<Base[], Del, Derived*, const Del&>(), "" );
78static_assert( ! check<Base[], Del, Derived*, Del>(), "" );