]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/experimental/net/buffer/traits.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / experimental / net / buffer / traits.cc
CommitLineData
99dee823 1// Copyright (C) 2015-2021 Free Software Foundation, Inc.
e5989e71
JW
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
7e8b87e9 18// { dg-do compile { target c++14 } }
e5989e71
JW
19
20#include <experimental/buffer>
21
22using namespace std::experimental::net;
23using std::vector;
24using std::string;
25using std::char_traits;
26using std::allocator;
27
28template<typename T>
29struct Seq {
30 struct Buf {
31 operator T() const { return {}; }
32 };
33
34 Buf* begin() const { return nullptr; }
35 Buf* end() const { return nullptr; }
36};
37
38static_assert( is_mutable_buffer_sequence<mutable_buffer>::value,
39 "mutable_buffer is a mutable buffer sequence" );
40static_assert( is_mutable_buffer_sequence<const mutable_buffer>::value,
41 "const mutable_buffer is a mutable buffer sequence" );
42static_assert( is_mutable_buffer_sequence<vector<mutable_buffer>>::value,
43 "vector<mutable_buffer> is a mutable buffer sequence" );
44static_assert( is_mutable_buffer_sequence<const vector<mutable_buffer>>::value,
45 "const vector<mutable_buffer> is a mutable buffer sequence" );
46static_assert( is_mutable_buffer_sequence<Seq<mutable_buffer>>::value,
47 "Seq<mutable_buffer> is a mutable buffer sequence" );
48static_assert( is_mutable_buffer_sequence<const Seq<mutable_buffer>>::value,
49 "const Seq<mutable_buffer> is a mutable buffer sequence" );
50static_assert( is_mutable_buffer_sequence<Seq<const mutable_buffer>>::value,
51 "Seq<const mutable_buffer> is a mutable buffer sequence" );
52static_assert( ! is_mutable_buffer_sequence<const_buffer>::value,
53 "const_buffer is not a mutable buffer sequence" );
54static_assert( ! is_mutable_buffer_sequence<vector<const_buffer>>::value,
55 "vector<const_buffer> is not a mutable buffer sequence" );
56static_assert( ! is_mutable_buffer_sequence<Seq<const_buffer>>::value,
57 "Seq<const_buffer> is not a mutable buffer sequence" );
58
59static_assert( is_const_buffer_sequence<const_buffer>::value,
60 "const_buffer is a const buffer sequence" );
61static_assert( is_const_buffer_sequence<const const_buffer>::value,
62 "const const_buffer is a const buffer sequence" );
63static_assert( is_const_buffer_sequence<vector<const_buffer>>::value,
64 "vector<const_buffer> is a const buffer sequence" );
65static_assert( is_const_buffer_sequence<const vector<const_buffer>>::value,
66 "const vector<const_buffer> is a const buffer sequence" );
67static_assert( is_const_buffer_sequence<Seq<const_buffer>>::value,
68 "Seq<const_buffer> is a const buffer sequence" );
69static_assert( is_const_buffer_sequence<const Seq<const_buffer>>::value,
70 "const Seq<const_buffer> is a const buffer sequence" );
71static_assert( is_const_buffer_sequence<Seq<const const_buffer>>::value,
72 "Seq<const const_buffer> is a const buffer sequence" );
73static_assert( is_const_buffer_sequence<mutable_buffer>::value,
74 "mutable_buffer is a const buffer sequence" );
75static_assert( is_const_buffer_sequence<const mutable_buffer>::value,
76 "const mutable_buffer is a const buffer sequence" );
77static_assert( is_const_buffer_sequence<vector<mutable_buffer>>::value,
78 "vector<mutable_buffer> is a const buffer sequence" );
79static_assert( is_const_buffer_sequence<const vector<mutable_buffer>>::value,
80 "const vector<mutable_buffer> is a const buffer sequence" );
81
82// Buf -> mutable_buffer -> const_buffer needs two user-defined conversions:
83static_assert( ! is_const_buffer_sequence<Seq<mutable_buffer>>::value,
84 "Seq<mutable_buffer> is not a const buffer sequence" );
85
86static_assert( is_dynamic_buffer<
87 dynamic_vector_buffer<int, allocator<int>>
88 >::value, "dynamic_vector_buffer is a dynamic buffer" );
89static_assert( is_dynamic_buffer<
90 dynamic_string_buffer<char, char_traits<char>, allocator<int>>
91 >::value, "dynamic_string_buffer is a dynamic buffer" );
92static_assert( ! is_dynamic_buffer<vector<int>>::value,
93 "vector is not a dynamic buffer" );
94static_assert( ! is_dynamic_buffer<string>::value,
95 "string is not a dynamic buffer" );