Output CodeView function information
[official-gcc.git] / libstdc++-v3 / testsuite / 23_containers / span / nothrow_cons.cc
blob3c445b18c1f53d25acdc8f4d6111ed65b656d851
1 // Copyright (C) 2019-2024 Free Software Foundation, Inc.
2 //
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)
7 // any later version.
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 } }
20 #include <span>
22 using std::span;
23 using std::is_nothrow_constructible_v;
25 static_assert( is_nothrow_constructible_v<span<int>> );
26 static_assert( is_nothrow_constructible_v<span<int, 0>> );
28 static_assert( is_nothrow_constructible_v<span<int>, span<int>&> );
29 static_assert( is_nothrow_constructible_v<span<const int>, span<int>&> );
30 static_assert( is_nothrow_constructible_v<span<int>, span<int, 1>&> );
31 static_assert( is_nothrow_constructible_v<span<const int>, span<int, 1>&> );
32 static_assert( is_nothrow_constructible_v<span<int, 1>, span<int, 1>&> );
33 static_assert( is_nothrow_constructible_v<span<const int, 1>, span<int, 1>&> );
35 static_assert( is_nothrow_constructible_v<span<int>, int(&)[1]> );
36 static_assert( is_nothrow_constructible_v<span<int, 1>, int(&)[1]> );
37 static_assert( is_nothrow_constructible_v<span<int>, std::array<int, 1>&> );
38 static_assert( is_nothrow_constructible_v<span<int, 1>, std::array<int, 1>&> );
40 template<bool>
41 struct sentinel { int* p; };
43 template<bool B>
44 bool operator==(sentinel<B> s, int* p) noexcept { return s.p == p; }
46 template<bool B>
47 std::ptrdiff_t operator-(sentinel<B> s, int* p) noexcept(B) { return s.p - p; }
49 template<bool B>
50 std::ptrdiff_t operator-(int* p, sentinel<B> s) noexcept { return p - s.p; }
52 static_assert(std::sized_sentinel_for<sentinel<true>, int*>);
53 static_assert(std::sized_sentinel_for<sentinel<false>, int*>);
55 static_assert(is_nothrow_constructible_v<span<int>, int*, std::size_t>);
56 static_assert(is_nothrow_constructible_v<span<int>, int*, const int*>);
57 static_assert(is_nothrow_constructible_v<span<int>, int*, sentinel<true>>);
58 static_assert(!is_nothrow_constructible_v<span<int>, int*, sentinel<false>>);