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