]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/is_nothrow_constructible/value_c++20.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / is_nothrow_constructible / value_c++20.cc
1 // { dg-options "-std=gnu++2a" }
2 // { dg-do compile { target c++2a } }
3
4 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
20
21 #include <type_traits>
22
23 static_assert( std::is_nothrow_constructible_v<int[1]> );
24 static_assert( std::is_nothrow_constructible_v<int[1], int> );
25 static_assert( std::is_nothrow_constructible_v<int[2], int> );
26 static_assert( std::is_nothrow_constructible_v<int[2], int, int> );
27 static_assert( ! std::is_nothrow_constructible_v<int[1], int, int> );
28 static_assert( ! std::is_nothrow_constructible_v<int[]> );
29 static_assert( ! std::is_nothrow_constructible_v<int[], int> );
30 static_assert( ! std::is_nothrow_constructible_v<int[], int, int> );
31
32 struct X
33 {
34 X() = default;
35 X(int) noexcept { }
36 X(double) { }
37 };
38
39 static_assert( std::is_nothrow_constructible_v<X[2]> );
40 static_assert( std::is_nothrow_constructible_v<X[1], X> );
41 static_assert( std::is_nothrow_constructible_v<X[1], int> );
42 static_assert( ! std::is_nothrow_constructible_v<X[1], double> );
43 static_assert( ! std::is_nothrow_constructible_v<X[2], int, double> );
44
45 struct Y
46 {
47 int i;
48 X x;
49 };
50
51 static_assert( std::is_nothrow_constructible_v<Y> );
52 static_assert( std::is_nothrow_constructible_v<Y, Y> );
53 static_assert( std::is_nothrow_constructible_v<Y, int> );
54 static_assert( ! std::is_nothrow_constructible_v<Y, X> );
55 static_assert( std::is_nothrow_constructible_v<Y, int, X> );
56 static_assert( std::is_nothrow_constructible_v<Y, int, int> );
57 static_assert( ! std::is_nothrow_constructible_v<Y, int, double> );
58
59 struct Z : Y { };
60
61 static_assert( std::is_nothrow_constructible_v<Z> );
62 static_assert( std::is_nothrow_constructible_v<Z, Z> );
63 static_assert( std::is_nothrow_constructible_v<Z, Y> );
64 static_assert( ! std::is_nothrow_constructible_v<Z, int> );
65 static_assert( ! std::is_nothrow_constructible_v<Z, int, X> );
66 static_assert( ! std::is_nothrow_constructible_v<Z, int, int> );
67 static_assert( ! std::is_nothrow_constructible_v<Z, Y, double> );
68 static_assert( ! std::is_nothrow_constructible_v<Z, int, double> );
69 static_assert( ! std::is_nothrow_constructible_v<Z, X> );