]>
Commit | Line | Data |
---|---|---|
0f7cd5e5 JW |
1 | // Copyright (C) 2020 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. | |
8 | ||
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. | |
13 | ||
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/>. | |
17 | ||
18 | // { dg-options "-std=gnu++2a" } | |
19 | // { dg-do compile { target c++2a } } | |
20 | ||
21 | #include <span> | |
22 | #include <cstddef> | |
23 | ||
24 | #if __has_include(<sys/uio.h>) | |
25 | #include <sys/uio.h> | |
26 | #else | |
27 | struct iovec { void* iov_base; std::size_t iov_len; }; | |
28 | #endif | |
29 | ||
30 | #if __cpp_lib_is_pointer_interconvertible | |
31 | using std::is_layout_compatible_v; | |
32 | #else | |
33 | // A poor substitute for is_layout_compatible_v | |
34 | template<typename T, typename U> | |
35 | constexpr bool is_layout_compatible_v | |
36 | = std::is_standard_layout_v<T> && std::is_standard_layout_v<U> | |
37 | && sizeof(T) == sizeof(U) && alignof(T) == alignof(U); | |
38 | #endif | |
39 | ||
40 | void | |
41 | test_pr95609() | |
42 | { | |
43 | using rbuf = std::span<const std::byte>; | |
44 | using wbuf = std::span<std::byte>; | |
45 | ||
46 | static_assert(is_layout_compatible_v<rbuf, struct iovec>); | |
47 | static_assert(is_layout_compatible_v<wbuf, struct iovec>); | |
48 | } |