• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>const_buffer</title>
5<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../boost_asio.html" title="Boost.Asio">
8<link rel="up" href="../reference.html" title="Reference">
9<link rel="prev" href="connect/overload12.html" title="connect (12 of 12 overloads)">
10<link rel="next" href="const_buffer/const_buffer.html" title="const_buffer::const_buffer">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
15<td align="center"><a href="../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="connect/overload12.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="const_buffer/const_buffer.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="section">
26<div class="titlepage"><div><div><h3 class="title">
27<a name="boost_asio.reference.const_buffer"></a><a class="link" href="const_buffer.html" title="const_buffer">const_buffer</a>
28</h3></div></div></div>
29<p>
30        Holds a buffer that cannot be modified.
31      </p>
32<pre class="programlisting">class const_buffer
33</pre>
34<h5>
35<a name="boost_asio.reference.const_buffer.h0"></a>
36        <span class="phrase"><a name="boost_asio.reference.const_buffer.member_functions"></a></span><a class="link" href="const_buffer.html#boost_asio.reference.const_buffer.member_functions">Member
37        Functions</a>
38      </h5>
39<div class="informaltable"><table class="table">
40<colgroup>
41<col>
42<col>
43</colgroup>
44<thead><tr>
45<th>
46                <p>
47                  Name
48                </p>
49              </th>
50<th>
51                <p>
52                  Description
53                </p>
54              </th>
55</tr></thead>
56<tbody>
57<tr>
58<td>
59                <p>
60                  <a class="link" href="const_buffer/const_buffer.html" title="const_buffer::const_buffer"><span class="bold"><strong>const_buffer</strong></span></a> <span class="silver">[constructor]</span>
61                </p>
62              </td>
63<td>
64                <p>
65                  Construct an empty buffer. <br> <span class="silver"> —</span><br> Construct a buffer to
66                  represent a given memory range. <br> <span class="silver"> —</span><br> Construct a non-modifiable
67                  buffer from a modifiable one.
68                </p>
69              </td>
70</tr>
71<tr>
72<td>
73                <p>
74                  <a class="link" href="const_buffer/data.html" title="const_buffer::data"><span class="bold"><strong>data</strong></span></a>
75                </p>
76              </td>
77<td>
78                <p>
79                  Get a pointer to the beginning of the memory range.
80                </p>
81              </td>
82</tr>
83<tr>
84<td>
85                <p>
86                  <a class="link" href="const_buffer/operator_plus__eq_.html" title="const_buffer::operator+="><span class="bold"><strong>operator+=</strong></span></a>
87                </p>
88              </td>
89<td>
90                <p>
91                  Move the start of the buffer by the specified number of bytes.
92                </p>
93              </td>
94</tr>
95<tr>
96<td>
97                <p>
98                  <a class="link" href="const_buffer/size.html" title="const_buffer::size"><span class="bold"><strong>size</strong></span></a>
99                </p>
100              </td>
101<td>
102                <p>
103                  Get the size of the memory range.
104                </p>
105              </td>
106</tr>
107</tbody>
108</table></div>
109<h5>
110<a name="boost_asio.reference.const_buffer.h1"></a>
111        <span class="phrase"><a name="boost_asio.reference.const_buffer.related_functions"></a></span><a class="link" href="const_buffer.html#boost_asio.reference.const_buffer.related_functions">Related
112        Functions</a>
113      </h5>
114<div class="informaltable"><table class="table">
115<colgroup>
116<col>
117<col>
118</colgroup>
119<thead><tr>
120<th>
121                <p>
122                  Name
123                </p>
124              </th>
125<th>
126                <p>
127                  Description
128                </p>
129              </th>
130</tr></thead>
131<tbody><tr>
132<td>
133                <p>
134                  <a class="link" href="const_buffer/operator_plus_.html" title="const_buffer::operator+"><span class="bold"><strong>operator+</strong></span></a>
135                </p>
136              </td>
137<td>
138                <p>
139                  Create a new non-modifiable buffer that is offset from the start
140                  of another.
141                </p>
142              </td>
143</tr></tbody>
144</table></div>
145<p>
146        The <a class="link" href="const_buffer.html" title="const_buffer"><code class="computeroutput">const_buffer</code></a>
147        class provides a safe representation of a buffer that cannot be modified.
148        It does not own the underlying data, and so is cheap to copy or assign.
149      </p>
150<h5>
151<a name="boost_asio.reference.const_buffer.h2"></a>
152        <span class="phrase"><a name="boost_asio.reference.const_buffer.accessing_buffer_contents"></a></span><a class="link" href="const_buffer.html#boost_asio.reference.const_buffer.accessing_buffer_contents">Accessing
153        Buffer Contents</a>
154      </h5>
155<p>
156        The contents of a buffer may be accessed using the <code class="computeroutput">data()</code> and
157        <code class="computeroutput">size()</code> member functions:
158      </p>
159<pre class="programlisting">boost::asio::const_buffer b1 = ...;
160std::size_t s1 = b1.size();
161const unsigned char* p1 = static_cast&lt;const unsigned char*&gt;(b1.data());
162</pre>
163<p>
164        The <code class="computeroutput">data()</code> member function permits violations of type safety,
165        so uses of it in application code should be carefully considered.
166      </p>
167<h5>
168<a name="boost_asio.reference.const_buffer.h3"></a>
169        <span class="phrase"><a name="boost_asio.reference.const_buffer.requirements"></a></span><a class="link" href="const_buffer.html#boost_asio.reference.const_buffer.requirements">Requirements</a>
170      </h5>
171<p>
172        <span class="emphasis"><em>Header: </em></span><code class="literal">boost/asio/buffer.hpp</code>
173      </p>
174<p>
175        <span class="emphasis"><em>Convenience header: </em></span><code class="literal">boost/asio.hpp</code>
176      </p>
177</div>
178<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
179<td align="left"></td>
180<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M.
181      Kohlhoff<p>
182        Distributed under the Boost Software License, Version 1.0. (See accompanying
183        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
184      </p>
185</div></td>
186</tr></table>
187<hr>
188<div class="spirit-nav">
189<a accesskey="p" href="connect/overload12.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="const_buffer/const_buffer.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
190</div>
191</body>
192</html>
193