1 // Copyright (C) 2019-2025 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++20 } }
24 using std::dynamic_extent
;
26 using std::is_constructible_v
;
28 // LWG 3255 span's array constructor is too strict
30 static_assert( is_constructible_v
<span
<const int* const>, array
<int*, 2>> );
31 static_assert( is_constructible_v
<span
<const int>, array
<const int, 4>> );
33 static_assert( is_constructible_v
<span
<int, 1>, int(&)[1]> );
34 static_assert( is_constructible_v
<span
<const int, 1>, int(&)[1]> );
35 static_assert( is_constructible_v
<span
<const int, 1>, const int(&)[1]> );
37 static_assert( is_constructible_v
<span
<int, 1>, array
<int, 1>&> );
38 static_assert( is_constructible_v
<span
<const int, 1>, array
<int, 1>&> );
39 static_assert( is_constructible_v
<span
<const int, 1>, array
<const int, 1>&> );
41 static_assert( is_constructible_v
<span
<const int, 1>, const array
<int, 1>&> );
42 static_assert( is_constructible_v
<span
<const int, 1>, const array
<const int, 1>&> );
44 static_assert( !is_constructible_v
<span
<int, 1>, int(&)[2]> );
45 static_assert( !is_constructible_v
<span
<const int, 1>, int(&)[2]> );
46 static_assert( !is_constructible_v
<span
<const int, 1>, const int(&)[2]> );
48 static_assert( !is_constructible_v
<span
<int, 1>, array
<int, 2>&> );
49 static_assert( !is_constructible_v
<span
<const int, 1>, array
<int, 2>&> );
50 static_assert( !is_constructible_v
<span
<const int, 1>, array
<const int, 2>&> );
52 static_assert( !is_constructible_v
<span
<int, 1>, const array
<int, 2>&> );
53 static_assert( !is_constructible_v
<span
<const int, 1>, const array
<int, 2>&> );
54 static_assert( !is_constructible_v
<span
<const int, 1>, const array
<const int, 2>&> );
56 static_assert( is_constructible_v
<span
<int>, int(&)[2]> );
57 static_assert( is_constructible_v
<span
<const int>, int(&)[2]> );
58 static_assert( is_constructible_v
<span
<const int>, const int(&)[2]> );
59 static_assert( is_constructible_v
<span
<const int>, int[2]> );
60 static_assert( is_constructible_v
<span
<const int>, const int[2]> );
62 static_assert( is_constructible_v
<span
<int>, array
<int, 2>&> );
63 static_assert( is_constructible_v
<span
<const int>, array
<int, 2>&> );
64 static_assert( is_constructible_v
<span
<const int>, array
<const int, 2>&> );
65 static_assert( is_constructible_v
<span
<const int>, array
<int, 2>> );
66 static_assert( is_constructible_v
<span
<const int>, array
<const int, 2>> );
68 static_assert( is_constructible_v
<span
<const int>, const array
<int, 2>&> );
69 static_assert( is_constructible_v
<span
<const int>, const array
<const int, 2>&> );
71 static_assert( ! is_constructible_v
<span
<int, 1>, array
<const int, 1>&> );
72 static_assert( ! is_constructible_v
<span
<int, 1>, const array
<int, 1>&> );
73 static_assert( ! is_constructible_v
<span
<int, 1>, const array
<const int, 1>&> );
74 static_assert( ! is_constructible_v
<span
<int>, array
<const int, 2>&> );
75 static_assert( ! is_constructible_v
<span
<int>, const array
<int, 2>&> );
76 static_assert( ! is_constructible_v
<span
<int>, const array
<const int, 2>&> );