]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/unique_ptr/cons/lwg2905.cc
1 // Copyright (C) 2017-2021 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-do compile { target c++11 } }
22 template<typename T
, typename D
, typename P
, typename E
>
23 constexpr bool check()
24 { return std::is_constructible
<std::unique_ptr
<T
, D
>, P
, E
>::value
; }
26 struct Del
{ void operator()(void*) const { } };
28 static_assert( ! check
<int, Del
&, int*, Del
>(), "" );
29 static_assert( check
<int, Del
&, int*, Del
&>(), "" );
30 static_assert( check
<int, const Del
&, int*, Del
&>(), "" );
31 static_assert( ! check
<int, Del
&, int*, const Del
&>(), "" );
32 static_assert( check
<int, Del
, int*, const Del
&>(), "" );
33 static_assert( check
<int, Del
, int*, Del
>(), "" );
35 static_assert( ! check
<int[], Del
&, int*, Del
>(), "" );
36 static_assert( check
<int[], Del
&, int*, Del
&>(), "" );
37 static_assert( check
<int[], const Del
&, int*, Del
&>(), "" );
38 static_assert( ! check
<int[], Del
&, int*, const Del
&>(), "" );
39 static_assert( check
<int[], Del
, int*, const Del
&>(), "" );
40 static_assert( check
<int[], Del
, int*, Del
>(), "" );
43 DelNoCopy() = default;
44 DelNoCopy(const DelNoCopy
&) = delete;
45 DelNoCopy(DelNoCopy
&&) = default;
46 void operator()(void*) const { }
49 static_assert( ! check
<int, DelNoCopy
&, int*, DelNoCopy
>(), "" );
50 static_assert( check
<int, DelNoCopy
&, int*, DelNoCopy
&>(), "" );
51 static_assert( check
<int, const DelNoCopy
&, int*, DelNoCopy
&>(), "" );
52 static_assert( ! check
<int, DelNoCopy
&, int*, const DelNoCopy
&>(), "" );
53 static_assert( ! check
<int, DelNoCopy
, int*, const DelNoCopy
&>(), "" );
54 static_assert( check
<int, DelNoCopy
, int*, DelNoCopy
>(), "" );
56 static_assert( ! check
<int[], DelNoCopy
&, int*, DelNoCopy
>(), "" );
57 static_assert( check
<int[], DelNoCopy
&, int*, DelNoCopy
&>(), "" );
58 static_assert( check
<int[], const DelNoCopy
&, int*, DelNoCopy
&>(), "" );
59 static_assert( ! check
<int[], DelNoCopy
&, int*, const DelNoCopy
&>(), "" );
60 static_assert( ! check
<int[], DelNoCopy
, int*, const DelNoCopy
&>(), "" );
61 static_assert( check
<int[], DelNoCopy
, int*, DelNoCopy
>(), "" );
63 struct Base
{ virtual ~Base() { } };
64 struct Derived
: Base
{ };
66 static_assert( ! check
<Base
[], Del
&, Base
*, Del
>(), "" );
67 static_assert( check
<Base
[], Del
&, Base
*, Del
&>(), "" );
68 static_assert( check
<Base
[], const Del
&, Base
*, Del
&>(), "" );
69 static_assert( ! check
<Base
[], Del
&, Base
*, const Del
&>(), "" );
70 static_assert( check
<Base
[], Del
, Base
*, const Del
&>(), "" );
71 static_assert( check
<Base
[], Del
, Base
*, Del
>(), "" );
73 static_assert( ! check
<Base
[], Del
&, Derived
*, Del
>(), "" );
74 static_assert( ! check
<Base
[], Del
&, Derived
*, Del
&>(), "" );
75 static_assert( ! check
<Base
[], const Del
&, Derived
*, Del
&>(), "" );
76 static_assert( ! check
<Base
[], Del
&, Derived
*, const Del
&>(), "" );
77 static_assert( ! check
<Base
[], Del
, Derived
*, const Del
&>(), "" );
78 static_assert( ! check
<Base
[], Del
, Derived
*, Del
>(), "" );