1 // Copyright (C) 2015-2019 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::mutable_buffer
;
28 using B
= mutable_buffer
;
31 static_assert( std::is_nothrow_default_constructible
<B
>::value
,
32 "const_mutable is nothrow default constructible" );
33 static_assert( std::is_copy_assignable
<B
>::value
,
34 "const_mutable is copy assignable" );
35 static_assert( std::is_nothrow_constructible
<B
, void*, size_t>::value
,
36 "const_mutable is nothrow default constructible" );
37 static_assert( std::is_same
<decltype(b
.data()), void*>::value
,
38 "data() return const void*" );
39 static_assert( noexcept(b
.data()),
40 "data() is nothrow" );
41 static_assert( std::is_same
<decltype(b
.size()), size_t>::value
,
42 "size() return size_t" );
43 static_assert( noexcept(b
.size()),
44 "size() is nothrow" );
50 bool test
__attribute__((unused
)) = false;
54 VERIFY( b
.data() == nullptr );
55 VERIFY( b
.size() == 0 );
57 b
= mutable_buffer(c
, sizeof(c
));
58 VERIFY( b
.data() == c
);
59 VERIFY( b
.size() == sizeof(c
) );
62 VERIFY( b
.data() == nullptr );
63 VERIFY( b
.size() == 0 );