summaryrefslogtreecommitdiff
path: root/libs/asio/doc/requirements/ConstBufferSequence.qbk
blob: 7314cd0d1339a8a26ae36d0b4b535cd3babad548 (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
96
97
98
99
100
101
102
[/
 / Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
 /
 / Distributed under the Boost Software License, Version 1.0. (See accompanying
 / file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 /]

[section:ConstBufferSequence Constant buffer sequence requirements]

In the table below, `X` denotes a class containing objects of type `T`, `a`
denotes a value of type `X` and `u` denotes an identifier.

[table ConstBufferSequence requirements
  [[expression] [return type] [assertion/note\npre/post-condition]]
  [
    [`X::value_type`]
    [`T`]
    [`T` meets the requirements for [link
     boost_asio.reference.ConvertibleToConstBuffer
     ConvertibleToConstBuffer].]
  ]
  [
    [`X::const_iterator`]
    [iterator type pointing to `T`]
    [`const_iterator` meets the requirements for bidirectional iterators
     (C++ Std, 24.1.4).]
  ]
  [
    [`X(a);`]
    []
    [post: `equal_const_buffer_seq(a, X(a))` where the binary predicate
     `equal_const_buffer_seq` is defined as
     ``
       bool equal_const_buffer_seq(
         const X& x1, const X& x2)
       {
         return
           distance(x1.begin(), x1.end())
             == distance(x2.begin(), x2.end())
               && equal(x1.begin(), x1.end(),
                        x2.begin(), equal_buffer);
       }
     ``
     and the binary predicate `equal_buffer` is defined as
     ``
      bool equal_buffer(
        const X::value_type& v1,
        const X::value_type& v2)
      {
        const_buffer b1(v1);
        const_buffer b2(v2);
        return
          buffer_cast<const void*>(b1)
            == buffer_cast<const void*>(b2)
              && buffer_size(b1) == buffer_size(b2);
      }
     ``]
  ]
  [
    [`X u(a);`]
    []
    [post:
     ``
      distance(a.begin(), a.end())
        == distance(u.begin(), u.end())
          && equal(a.begin(), a.end(),
                   u.begin(), equal_buffer)
     ``
     where the binary predicate `equal_buffer` is defined as
     ``
      bool equal_buffer(
        const X::value_type& v1,
        const X::value_type& v2)
      {
        const_buffer b1(v1);
        const_buffer b2(v2);
        return
          buffer_cast<const void*>(b1)
            == buffer_cast<const void*>(b2)
              && buffer_size(b1) == buffer_size(b2);
      }
     ``]
  ]
  [
    [`(&a)->~X();`]
    [`void`]
    [note: the destructor is applied to every element of `a`; all the memory
     is deallocated.]
  ]
  [
    [`a.begin();`]
    [`const_iterator` or convertible to `const_iterator`]
    []
  ]
  [
    [`a.end();`]
    [`const_iterator` or convertible to `const_iterator`]
    []
  ]
]

[endsect]