]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.constructible/1.cc
1 // Copyright (C) 2019-2020 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++2a" }
19 // { dg-do compile { target c++2a } }
23 static_assert( !std::constructible_from
<void> );
24 static_assert( !std::constructible_from
<void, void> );
25 static_assert( std::constructible_from
<void*, int*> );
26 static_assert( !std::constructible_from
<void*, const int*> );
27 static_assert( std::constructible_from
<const void*, const int*> );
28 static_assert( std::constructible_from
<char> );
29 static_assert( std::constructible_from
<float> );
30 static_assert( std::constructible_from
<float, float> );
31 static_assert( std::constructible_from
<float, double> );
32 static_assert( std::constructible_from
<int*> );
33 static_assert( std::constructible_from
<int*, int*> );
34 static_assert( !std::constructible_from
<int&> );
35 static_assert( std::constructible_from
<int&, int&> );
36 static_assert( !std::constructible_from
<int&&> );
37 static_assert( std::constructible_from
<int&&, int> );
38 static_assert( !std::constructible_from
<const int&> );
39 static_assert( std::constructible_from
<const int&, int> );
40 static_assert( std::constructible_from
<const int&, int&> );
41 static_assert( std::constructible_from
<const int&, const int> );
42 static_assert( std::constructible_from
<const int&, const int&> );
43 static_assert( !std::constructible_from
<const int&, int, int> );
44 static_assert( !std::constructible_from
<int[]> );
45 static_assert( std::constructible_from
<int[2]> );
46 static_assert( !std::constructible_from
<int()> );
47 static_assert( std::constructible_from
<int(*)()> );
48 static_assert( std::constructible_from
<int(*)(), std::nullptr_t
> );
49 static_assert( std::constructible_from
<int(*)(), int(*)() noexcept
> );
50 static_assert( std::constructible_from
<int(*)(), int(&)() noexcept
> );
51 static_assert( !std::constructible_from
<int(&)()> );
52 static_assert( std::constructible_from
<int(&)(), int(&)() noexcept
> );
55 static_assert( std::constructible_from
<E
> );
56 static_assert( std::constructible_from
<E
, E
&> );
58 static_assert( std::constructible_from
<CE
> );
59 static_assert( std::constructible_from
<CE
, CE
&> );
61 static_assert( std::constructible_from
<A
> );
62 static_assert( std::constructible_from
<A
, A
> );
63 static_assert( std::constructible_from
<A
, A
&> );
64 static_assert( std::constructible_from
<A
, const A
&> );
66 static_assert( std::constructible_from
<B
> );
67 static_assert( std::constructible_from
<B
, B
> );
68 static_assert( std::constructible_from
<B
, B
&> );
69 static_assert( std::constructible_from
<B
, const B
&> );
73 C(void* = nullptr) { }
74 ~C() noexcept(false) { }
76 static_assert( !std::constructible_from
<C
> );
77 static_assert( !std::constructible_from
<C
, void*> );
78 static_assert( !std::constructible_from
<C
, std::nullptr_t
> );
88 static_assert( !std::constructible_from
<D
> );
89 static_assert( !std::constructible_from
<D
, int> );