summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/experimental/net/buffer/traits.cc
blob: 6f4e27c9235da2a4409e1e75d8bb985d36f4b10d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// Copyright (C) 2015-2019 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3.  If not see
// <http://www.gnu.org/licenses/>.

// { dg-do compile { target c++14 } }

#include <experimental/buffer>

using namespace std::experimental::net;
using std::vector;
using std::string;
using std::char_traits;
using std::allocator;

template<typename T>
struct Seq {
  struct Buf {
    operator T() const { return {}; }
  };

  Buf* begin() const { return nullptr; }
  Buf* end() const { return nullptr; }
};

static_assert( is_mutable_buffer_sequence<mutable_buffer>::value,
    "mutable_buffer is a mutable buffer sequence" );
static_assert( is_mutable_buffer_sequence<const mutable_buffer>::value,
    "const mutable_buffer is a mutable buffer sequence" );
static_assert( is_mutable_buffer_sequence<vector<mutable_buffer>>::value,
    "vector<mutable_buffer> is a mutable buffer sequence" );
static_assert( is_mutable_buffer_sequence<const vector<mutable_buffer>>::value,
    "const vector<mutable_buffer> is a mutable buffer sequence" );
static_assert( is_mutable_buffer_sequence<Seq<mutable_buffer>>::value,
    "Seq<mutable_buffer> is a mutable buffer sequence" );
static_assert( is_mutable_buffer_sequence<const Seq<mutable_buffer>>::value,
    "const Seq<mutable_buffer> is a mutable buffer sequence" );
static_assert( is_mutable_buffer_sequence<Seq<const mutable_buffer>>::value,
    "Seq<const mutable_buffer> is a mutable buffer sequence" );
static_assert( ! is_mutable_buffer_sequence<const_buffer>::value,
    "const_buffer is not a mutable buffer sequence" );
static_assert( ! is_mutable_buffer_sequence<vector<const_buffer>>::value,
    "vector<const_buffer> is not a mutable buffer sequence" );
static_assert( ! is_mutable_buffer_sequence<Seq<const_buffer>>::value,
    "Seq<const_buffer> is not a mutable buffer sequence" );

static_assert( is_const_buffer_sequence<const_buffer>::value,
    "const_buffer is a const buffer sequence" );
static_assert( is_const_buffer_sequence<const const_buffer>::value,
    "const const_buffer is a const buffer sequence" );
static_assert( is_const_buffer_sequence<vector<const_buffer>>::value,
    "vector<const_buffer> is a const buffer sequence" );
static_assert( is_const_buffer_sequence<const vector<const_buffer>>::value,
    "const vector<const_buffer> is a const buffer sequence" );
static_assert( is_const_buffer_sequence<Seq<const_buffer>>::value,
    "Seq<const_buffer> is a const buffer sequence" );
static_assert( is_const_buffer_sequence<const Seq<const_buffer>>::value,
    "const Seq<const_buffer> is a const buffer sequence" );
static_assert( is_const_buffer_sequence<Seq<const const_buffer>>::value,
    "Seq<const const_buffer> is a const buffer sequence" );
static_assert( is_const_buffer_sequence<mutable_buffer>::value,
    "mutable_buffer is a const buffer sequence" );
static_assert( is_const_buffer_sequence<const mutable_buffer>::value,
    "const mutable_buffer is a const buffer sequence" );
static_assert( is_const_buffer_sequence<vector<mutable_buffer>>::value,
    "vector<mutable_buffer> is a const buffer sequence" );
static_assert( is_const_buffer_sequence<const vector<mutable_buffer>>::value,
    "const vector<mutable_buffer> is a const buffer sequence" );

// Buf -> mutable_buffer -> const_buffer needs two user-defined conversions:
static_assert( ! is_const_buffer_sequence<Seq<mutable_buffer>>::value,
    "Seq<mutable_buffer> is not a const buffer sequence" );

static_assert( is_dynamic_buffer<
    dynamic_vector_buffer<int, allocator<int>>
    >::value, "dynamic_vector_buffer is a dynamic buffer" );
static_assert( is_dynamic_buffer<
    dynamic_string_buffer<char, char_traits<char>, allocator<int>>
    >::value, "dynamic_string_buffer is a dynamic buffer" );
static_assert( ! is_dynamic_buffer<vector<int>>::value,
    "vector is not a dynamic buffer" );
static_assert( ! is_dynamic_buffer<string>::value,
    "string is not a dynamic buffer" );