1 // Copyright (C) 2015-2020 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 run { target c++14 } }
20 #include <experimental/buffer>
21 #include <testsuite_hooks.h>
23 using std::experimental::net::const_buffer
;
24 using std::experimental::net::mutable_buffer
;
29 using B
= const_buffer
;
32 static_assert( std::is_nothrow_default_constructible
<B
>::value
,
33 "const_mutable is nothrow default constructible" );
34 static_assert( std::is_copy_assignable
<B
>::value
,
35 "const_mutable is copy assignable" );
36 static_assert( std::is_nothrow_constructible
<B
, const void*, size_t>::value
,
37 "const_mutable is nothrow constructible from pointer and length" );
38 static_assert( std::is_nothrow_constructible
<B
, mutable_buffer
>::value
,
39 "const_mutable is nothrow constructible from mutable_buffer" );
40 static_assert( std::is_same
<decltype(b
.data()), const void*>::value
,
41 "data() return const void*" );
42 static_assert( noexcept(b
.data()),
43 "data() is nothrow" );
44 static_assert( std::is_same
<decltype(b
.size()), size_t>::value
,
45 "size() return size_t" );
46 static_assert( noexcept(b
.size()),
47 "size() is nothrow" );
53 bool test
__attribute__((unused
)) = false;
57 VERIFY( b
.data() == nullptr );
58 VERIFY( b
.size() == 0 );
60 b
= const_buffer(c
, sizeof(c
));
61 VERIFY( b
.data() == c
);
62 VERIFY( b
.size() == sizeof(c
) );
65 VERIFY( b
.data() == nullptr );
66 VERIFY( b
.size() == 0 );