643 lines
85 KiB
HTML
643 lines
85 KiB
HTML
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||
|
<title>buffer</title>
|
||
|
<link rel="stylesheet" href="../../boostbook.css" type="text/css">
|
||
|
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
|
||
|
<link rel="home" href="../../index.html" title="Asio">
|
||
|
<link rel="up" href="../reference.html" title="Reference">
|
||
|
<link rel="prev" href="bind_immediate_executor.html" title="bind_immediate_executor">
|
||
|
<link rel="next" href="buffer/overload1.html" title="buffer (1 of 42 overloads)">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
|
</head>
|
||
|
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
|
||
|
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="asio C++ library" width="250" height="60" src="../../asio.png"></td></tr></table>
|
||
|
<hr>
|
||
|
<div class="spirit-nav">
|
||
|
<a accesskey="p" href="bind_immediate_executor.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="buffer/overload1.html"><img src="../../next.png" alt="Next"></a>
|
||
|
</div>
|
||
|
<div class="section">
|
||
|
<div class="titlepage"><div><div><h3 class="title">
|
||
|
<a name="asio.reference.buffer"></a><a class="link" href="buffer.html" title="buffer">buffer</a>
|
||
|
</h3></div></div></div>
|
||
|
<p>
|
||
|
<a class="indexterm" name="asio.indexterm.buffer"></a>
|
||
|
</p>
|
||
|
<p>
|
||
|
The <code class="computeroutput"><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span></code> function is used to create a buffer
|
||
|
object to represent raw memory, an array of POD elements, a vector of POD
|
||
|
elements, or a std::string.
|
||
|
</p>
|
||
|
<p>
|
||
|
Create a new modifiable buffer from an existing buffer.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload1.html" title="buffer (1 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">mutable_buffer</span> <span class="special">&</span> <span class="identifier">b</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload1.html" title="buffer (1 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload2.html" title="buffer (2 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">mutable_buffer</span> <span class="special">&</span> <span class="identifier">b</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload2.html" title="buffer (2 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new non-modifiable buffer from an existing buffer.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">const_buffer</span> <a class="link" href="buffer/overload3.html" title="buffer (3 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">const_buffer</span> <span class="special">&</span> <span class="identifier">b</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload3.html" title="buffer (3 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload4.html" title="buffer (4 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">const_buffer</span> <span class="special">&</span> <span class="identifier">b</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload4.html" title="buffer (4 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new modifiable buffer that represents the given memory range.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload5.html" title="buffer (5 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">void</span> <span class="special">*</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload5.html" title="buffer (5 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new non-modifiable buffer that represents the given memory range.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">const_buffer</span> <a class="link" href="buffer/overload6.html" title="buffer (6 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="keyword">void</span> <span class="special">*</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload6.html" title="buffer (6 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new modifiable buffer that represents the given POD array.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload7.html" title="buffer (7 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">PodType</span> <span class="special">(&</span><span class="identifier">data</span><span class="special">)[</span><span class="identifier">N</span><span class="special">]);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload7.html" title="buffer (7 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload8.html" title="buffer (8 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">PodType</span> <span class="special">(&</span><span class="identifier">data</span><span class="special">)[</span><span class="identifier">N</span><span class="special">],</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload8.html" title="buffer (8 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new non-modifiable buffer that represents the given POD array.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload9.html" title="buffer (9 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">PodType</span> <span class="special">(&</span><span class="identifier">data</span><span class="special">)[</span><span class="identifier">N</span><span class="special">]);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload9.html" title="buffer (9 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload10.html" title="buffer (10 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">PodType</span> <span class="special">(&</span><span class="identifier">data</span><span class="special">)[</span><span class="identifier">N</span><span class="special">],</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload10.html" title="buffer (10 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new modifiable buffer that represents the given POD array.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload11.html" title="buffer (11 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload11.html" title="buffer (11 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload12.html" title="buffer (12 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload12.html" title="buffer (12 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new non-modifiable buffer that represents the given POD array.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload13.html" title="buffer (13 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="keyword">const</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload13.html" title="buffer (13 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload14.html" title="buffer (14 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="keyword">const</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload14.html" title="buffer (14 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload15.html" title="buffer (15 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload15.html" title="buffer (15 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload16.html" title="buffer (16 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload16.html" title="buffer (16 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new modifiable buffer that represents the given POD array.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload17.html" title="buffer (17 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload17.html" title="buffer (17 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload18.html" title="buffer (18 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload18.html" title="buffer (18 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new non-modifiable buffer that represents the given POD array.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload19.html" title="buffer (19 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="keyword">const</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload19.html" title="buffer (19 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload20.html" title="buffer (20 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="keyword">const</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload20.html" title="buffer (20 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload21.html" title="buffer (21 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload21.html" title="buffer (21 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload22.html" title="buffer (22 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">N</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload22.html" title="buffer (22 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new modifiable buffer that represents the given POD vector.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload23.html" title="buffer (23 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">Allocator</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload23.html" title="buffer (23 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload24.html" title="buffer (24 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">Allocator</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload24.html" title="buffer (24 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new non-modifiable buffer that represents the given POD vector.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload25.html" title="buffer (25 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">Allocator</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload25.html" title="buffer (25 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">PodType</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload26.html" title="buffer (26 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span> <span class="identifier">PodType</span><span class="special">,</span> <span class="identifier">Allocator</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload26.html" title="buffer (26 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new modifiable buffer that represents the given string.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Elem</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Traits</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload27.html" title="buffer (27 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special"><</span> <span class="identifier">Elem</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Allocator</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload27.html" title="buffer (27 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Elem</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Traits</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload28.html" title="buffer (28 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special"><</span> <span class="identifier">Elem</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Allocator</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload28.html" title="buffer (28 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new non-modifiable buffer that represents the given string.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Elem</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Traits</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload29.html" title="buffer (29 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special"><</span> <span class="identifier">Elem</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Allocator</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload29.html" title="buffer (29 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Elem</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Traits</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Allocator</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload30.html" title="buffer (30 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">basic_string</span><span class="special"><</span> <span class="identifier">Elem</span><span class="special">,</span> <span class="identifier">Traits</span><span class="special">,</span> <span class="identifier">Allocator</span> <span class="special">></span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload30.html" title="buffer (30 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new non-modifiable buffer that represents the given string_view.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Elem</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Traits</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload31.html" title="buffer (31 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">basic_string_view</span><span class="special"><</span> <span class="identifier">Elem</span><span class="special">,</span> <span class="identifier">Traits</span> <span class="special">></span> <span class="identifier">data</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload31.html" title="buffer (31 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new non-modifiable buffer that represents the given string.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Elem</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">Traits</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload32.html" title="buffer (32 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">basic_string_view</span><span class="special"><</span> <span class="identifier">Elem</span><span class="special">,</span> <span class="identifier">Traits</span> <span class="special">></span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload32.html" title="buffer (32 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new modifiable buffer from a contiguous container.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload33.html" title="buffer (33 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">T</span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="identifier">is_contiguous_iterator</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">const_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">mutable_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_const</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">remove_reference</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">>::</span><span class="identifier">reference</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">());</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload33.html" title="buffer (33 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||
|
<span class="identifier">mutable_buffer</span> <a class="link" href="buffer/overload34.html" title="buffer (34 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">T</span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="identifier">is_contiguous_iterator</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">const_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">mutable_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_const</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">remove_reference</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">>::</span><span class="identifier">reference</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">());</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload34.html" title="buffer (34 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Create a new non-modifiable buffer from a contiguous container.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload35.html" title="buffer (35 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">T</span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="identifier">is_contiguous_iterator</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">const_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">mutable_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="identifier">is_const</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">remove_reference</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">>::</span><span class="identifier">reference</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">());</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload35.html" title="buffer (35 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload36.html" title="buffer (36 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="identifier">T</span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="identifier">is_contiguous_iterator</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">const_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">mutable_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="identifier">is_const</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">remove_reference</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">iterator_traits</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">iterator</span> <span class="special">>::</span><span class="identifier">reference</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">());</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload36.html" title="buffer (36 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload37.html" title="buffer (37 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="identifier">is_contiguous_iterator</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">const_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">mutable_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">());</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload37.html" title="buffer (37 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="keyword">template</span><span class="special"><</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
|
||
|
<span class="identifier">const_buffer</span> <a class="link" href="buffer/overload38.html" title="buffer (38 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&</span> <span class="identifier">data</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">max_size_in_bytes</span><span class="special">,</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="identifier">is_contiguous_iterator</span><span class="special"><</span> <span class="keyword">typename</span> <span class="identifier">T</span><span class="special">::</span><span class="identifier">const_iterator</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">const_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">(),</span>
|
||
|
<span class="keyword">typename</span> <span class="identifier">constraint</span><span class="special"><</span> <span class="special">!</span><span class="identifier">is_convertible</span><span class="special"><</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">mutable_buffer</span> <span class="special">>::</span><span class="identifier">value</span><span class="special">,</span> <span class="identifier">defaulted_constraint</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">=</span> <span class="identifier">defaulted_constraint</span><span class="special">());</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload38.html" title="buffer (38 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Obtain a buffer representing the entire registered buffer.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">mutable_registered_buffer</span> <a class="link" href="buffer/overload39.html" title="buffer (39 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">mutable_registered_buffer</span> <span class="special">&</span> <span class="identifier">b</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload39.html" title="buffer (39 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="identifier">const_registered_buffer</span> <a class="link" href="buffer/overload40.html" title="buffer (40 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">const_registered_buffer</span> <span class="special">&</span> <span class="identifier">b</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload40.html" title="buffer (40 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Obtain a buffer representing part of a registered buffer.
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">mutable_registered_buffer</span> <a class="link" href="buffer/overload41.html" title="buffer (41 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">mutable_registered_buffer</span> <span class="special">&</span> <span class="identifier">b</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">n</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload41.html" title="buffer (41 of 42 overloads)">more...</a></em></span>
|
||
|
|
||
|
<span class="identifier">const_registered_buffer</span> <a class="link" href="buffer/overload42.html" title="buffer (42 of 42 overloads)">buffer</a><span class="special">(</span>
|
||
|
<span class="keyword">const</span> <span class="identifier">const_registered_buffer</span> <span class="special">&</span> <span class="identifier">b</span><span class="special">,</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">n</span><span class="special">);</span>
|
||
|
<span class="emphasis"><em>» <a class="link" href="buffer/overload42.html" title="buffer (42 of 42 overloads)">more...</a></em></span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
A buffer object represents a contiguous region of memory as a 2-tuple consisting
|
||
|
of a pointer and size in bytes. A tuple of the form <code class="computeroutput"><span class="special">{</span><span class="keyword">void</span><span class="special">*,</span> <span class="identifier">size_t</span><span class="special">}</span></code> specifies a mutable (modifiable) region
|
||
|
of memory. Similarly, a tuple of the form <code class="computeroutput"><span class="special">{</span><span class="keyword">const</span> <span class="keyword">void</span><span class="special">*,</span> <span class="identifier">size_t</span><span class="special">}</span></code> specifies a const (non-modifiable) region
|
||
|
of memory. These two forms correspond to the classes <a class="link" href="mutable_buffer.html" title="mutable_buffer"><code class="computeroutput"><span class="identifier">mutable_buffer</span></code></a> and <a class="link" href="const_buffer.html" title="const_buffer"><code class="computeroutput"><span class="identifier">const_buffer</span></code></a>, respectively. To mirror
|
||
|
C++'s conversion rules, a <a class="link" href="mutable_buffer.html" title="mutable_buffer"><code class="computeroutput"><span class="identifier">mutable_buffer</span></code></a> is implicitly convertible
|
||
|
to a <a class="link" href="const_buffer.html" title="const_buffer"><code class="computeroutput"><span class="identifier">const_buffer</span></code></a>,
|
||
|
and the opposite conversion is not permitted.
|
||
|
</p>
|
||
|
<p>
|
||
|
The simplest use case involves reading or writing a single buffer of a specified
|
||
|
size:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">sock</span><span class="special">.</span><span class="identifier">send</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">data</span><span class="special">,</span> <span class="identifier">size</span><span class="special">));</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
In the above example, the return value of <code class="computeroutput"><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span></code>
|
||
|
meets the requirements of the ConstBufferSequence concept so that it may
|
||
|
be directly passed to the socket's write function. A buffer created for modifiable
|
||
|
memory also meets the requirements of the MutableBufferSequence concept.
|
||
|
</p>
|
||
|
<p>
|
||
|
An individual buffer may be created from a builtin array, std::vector, std::array
|
||
|
or boost::array of POD elements. This helps prevent buffer overruns by automatically
|
||
|
determining the size of the buffer:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">char</span> <span class="identifier">d1</span><span class="special">[</span><span class="number">128</span><span class="special">];</span>
|
||
|
<span class="identifier">size_t</span> <span class="identifier">bytes_transferred</span> <span class="special">=</span> <span class="identifier">sock</span><span class="special">.</span><span class="identifier">receive</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">d1</span><span class="special">));</span>
|
||
|
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">char</span><span class="special">></span> <span class="identifier">d2</span><span class="special">(</span><span class="number">128</span><span class="special">);</span>
|
||
|
<span class="identifier">bytes_transferred</span> <span class="special">=</span> <span class="identifier">sock</span><span class="special">.</span><span class="identifier">receive</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">d2</span><span class="special">));</span>
|
||
|
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span><span class="keyword">char</span><span class="special">,</span> <span class="number">128</span><span class="special">></span> <span class="identifier">d3</span><span class="special">;</span>
|
||
|
<span class="identifier">bytes_transferred</span> <span class="special">=</span> <span class="identifier">sock</span><span class="special">.</span><span class="identifier">receive</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">d3</span><span class="special">));</span>
|
||
|
|
||
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span><span class="keyword">char</span><span class="special">,</span> <span class="number">128</span><span class="special">></span> <span class="identifier">d4</span><span class="special">;</span>
|
||
|
<span class="identifier">bytes_transferred</span> <span class="special">=</span> <span class="identifier">sock</span><span class="special">.</span><span class="identifier">receive</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">d4</span><span class="special">));</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
In all three cases above, the buffers created are exactly 128 bytes long.
|
||
|
Note that a vector is <span class="emphasis"><em>never</em></span> automatically resized when
|
||
|
creating or using a buffer. The buffer size is determined using the vector's
|
||
|
<code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code>
|
||
|
member function, and not its capacity.
|
||
|
</p>
|
||
|
<h5>
|
||
|
<a name="asio.reference.buffer.h0"></a>
|
||
|
<span><a name="asio.reference.buffer.accessing_buffer_contents"></a></span><a class="link" href="buffer.html#asio.reference.buffer.accessing_buffer_contents">Accessing
|
||
|
Buffer Contents</a>
|
||
|
</h5>
|
||
|
<p>
|
||
|
The contents of a buffer may be accessed using the <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code> and <code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code> member functions:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">asio</span><span class="special">::</span><span class="identifier">mutable_buffer</span> <span class="identifier">b1</span> <span class="special">=</span> <span class="special">...;</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">s1</span> <span class="special">=</span> <span class="identifier">b1</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span>
|
||
|
<span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">p1</span> <span class="special">=</span> <span class="keyword">static_cast</span><span class="special"><</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">*>(</span><span class="identifier">b1</span><span class="special">.</span><span class="identifier">data</span><span class="special">());</span>
|
||
|
|
||
|
<span class="identifier">asio</span><span class="special">::</span><span class="identifier">const_buffer</span> <span class="identifier">b2</span> <span class="special">=</span> <span class="special">...;</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">s2</span> <span class="special">=</span> <span class="identifier">b2</span><span class="special">.</span><span class="identifier">size</span><span class="special">();</span>
|
||
|
<span class="keyword">const</span> <span class="keyword">void</span><span class="special">*</span> <span class="identifier">p2</span> <span class="special">=</span> <span class="identifier">b2</span><span class="special">.</span><span class="identifier">data</span><span class="special">();</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
The <code class="computeroutput"><span class="identifier">data</span><span class="special">()</span></code>
|
||
|
member function permits violations of type safety, so uses of it in application
|
||
|
code should be carefully considered.
|
||
|
</p>
|
||
|
<p>
|
||
|
For convenience, a <a class="link" href="buffer_size.html" title="buffer_size"><code class="computeroutput"><span class="identifier">buffer_size</span></code></a> function is provided
|
||
|
that works with both buffers and buffer sequences (that is, types meeting
|
||
|
the ConstBufferSequence or MutableBufferSequence type requirements). In this
|
||
|
case, the function returns the total size of all buffers in the sequence.
|
||
|
</p>
|
||
|
<h5>
|
||
|
<a name="asio.reference.buffer.h1"></a>
|
||
|
<span><a name="asio.reference.buffer.buffer_copying"></a></span><a class="link" href="buffer.html#asio.reference.buffer.buffer_copying">Buffer
|
||
|
Copying</a>
|
||
|
</h5>
|
||
|
<p>
|
||
|
The <a class="link" href="buffer_copy.html" title="buffer_copy"><code class="computeroutput"><span class="identifier">buffer_copy</span></code></a>
|
||
|
function may be used to copy raw bytes between individual buffers and buffer
|
||
|
sequences.
|
||
|
</p>
|
||
|
<p>
|
||
|
In particular, when used with the <a class="link" href="buffer_size.html" title="buffer_size"><code class="computeroutput"><span class="identifier">buffer_size</span></code></a> function, the <a class="link" href="buffer_copy.html" title="buffer_copy"><code class="computeroutput"><span class="identifier">buffer_copy</span></code></a>
|
||
|
function can be used to linearise a sequence of buffers. For example:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">vector</span><span class="special"><</span><span class="identifier">const_buffer</span><span class="special">></span> <span class="identifier">buffers</span> <span class="special">=</span> <span class="special">...;</span>
|
||
|
|
||
|
<span class="identifier">vector</span><span class="special"><</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">></span> <span class="identifier">data</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer_size</span><span class="special">(</span><span class="identifier">buffers</span><span class="special">));</span>
|
||
|
<span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer_copy</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">data</span><span class="special">),</span> <span class="identifier">buffers</span><span class="special">);</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Note that <a class="link" href="buffer_copy.html" title="buffer_copy"><code class="computeroutput"><span class="identifier">buffer_copy</span></code></a>
|
||
|
is implemented in terms of <code class="computeroutput"><span class="identifier">memcpy</span></code>,
|
||
|
and consequently it cannot be used to copy between overlapping memory regions.
|
||
|
</p>
|
||
|
<h5>
|
||
|
<a name="asio.reference.buffer.h2"></a>
|
||
|
<span><a name="asio.reference.buffer.buffer_invalidation"></a></span><a class="link" href="buffer.html#asio.reference.buffer.buffer_invalidation">Buffer
|
||
|
Invalidation</a>
|
||
|
</h5>
|
||
|
<p>
|
||
|
A buffer object does not have any ownership of the memory it refers to. It
|
||
|
is the responsibility of the application to ensure the memory region remains
|
||
|
valid until it is no longer required for an I/O operation. When the memory
|
||
|
is no longer available, the buffer is said to have been invalidated.
|
||
|
</p>
|
||
|
<p>
|
||
|
For the <code class="computeroutput"><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span></code> overloads that accept an argument
|
||
|
of type std::vector, the buffer objects returned are invalidated by any vector
|
||
|
operation that also invalidates all references, pointers and iterators referring
|
||
|
to the elements in the sequence (C++ Std, 23.2.4)
|
||
|
</p>
|
||
|
<p>
|
||
|
For the <code class="computeroutput"><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span></code> overloads that accept an argument
|
||
|
of type std::basic_string, the buffer objects returned are invalidated according
|
||
|
to the rules defined for invalidation of references, pointers and iterators
|
||
|
referring to elements of the sequence (C++ Std, 21.3).
|
||
|
</p>
|
||
|
<h5>
|
||
|
<a name="asio.reference.buffer.h3"></a>
|
||
|
<span><a name="asio.reference.buffer.buffer_arithmetic"></a></span><a class="link" href="buffer.html#asio.reference.buffer.buffer_arithmetic">Buffer
|
||
|
Arithmetic</a>
|
||
|
</h5>
|
||
|
<p>
|
||
|
Buffer objects may be manipulated using simple arithmetic in a safe way which
|
||
|
helps prevent buffer overruns. Consider an array initialised as follows:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span><span class="keyword">char</span><span class="special">,</span> <span class="number">6</span><span class="special">></span> <span class="identifier">a</span> <span class="special">=</span> <span class="special">{</span> <span class="char">'a'</span><span class="special">,</span> <span class="char">'b'</span><span class="special">,</span> <span class="char">'c'</span><span class="special">,</span> <span class="char">'d'</span><span class="special">,</span> <span class="char">'e'</span> <span class="special">};</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
A buffer object <code class="computeroutput"><span class="identifier">b1</span></code> created
|
||
|
using:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">b1</span> <span class="special">=</span> <span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">a</span><span class="special">);</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
represents the entire array, <code class="computeroutput"><span class="special">{</span> <span class="char">'a'</span><span class="special">,</span> <span class="char">'b'</span><span class="special">,</span> <span class="char">'c'</span><span class="special">,</span>
|
||
|
<span class="char">'d'</span><span class="special">,</span> <span class="char">'e'</span> <span class="special">}</span></code>. An optional
|
||
|
second argument to the <code class="computeroutput"><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span></code>
|
||
|
function may be used to limit the size, in bytes, of the buffer:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">b2</span> <span class="special">=</span> <span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="number">3</span><span class="special">);</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
such that <code class="computeroutput"><span class="identifier">b2</span></code> represents the
|
||
|
data <code class="computeroutput"><span class="special">{</span> <span class="char">'a'</span><span class="special">,</span> <span class="char">'b'</span><span class="special">,</span>
|
||
|
<span class="char">'c'</span> <span class="special">}</span></code>.
|
||
|
Even if the size argument exceeds the actual size of the array, the size
|
||
|
of the buffer object created will be limited to the array size.
|
||
|
</p>
|
||
|
<p>
|
||
|
An offset may be applied to an existing buffer to create a new one:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">b3</span> <span class="special">=</span> <span class="identifier">b1</span> <span class="special">+</span> <span class="number">2</span><span class="special">;</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
where <code class="computeroutput"><span class="identifier">b3</span></code> will set to represent
|
||
|
<code class="computeroutput"><span class="special">{</span> <span class="char">'c'</span><span class="special">,</span> <span class="char">'d'</span><span class="special">,</span>
|
||
|
<span class="char">'e'</span> <span class="special">}</span></code>.
|
||
|
If the offset exceeds the size of the existing buffer, the newly created
|
||
|
buffer will be empty.
|
||
|
</p>
|
||
|
<p>
|
||
|
Both an offset and size may be specified to create a buffer that corresponds
|
||
|
to a specific range of bytes within an existing buffer:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="identifier">b4</span> <span class="special">=</span> <span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">b1</span> <span class="special">+</span> <span class="number">1</span><span class="special">,</span> <span class="number">3</span><span class="special">);</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
so that <code class="computeroutput"><span class="identifier">b4</span></code> will refer to
|
||
|
the bytes <code class="computeroutput"><span class="special">{</span> <span class="char">'b'</span><span class="special">,</span> <span class="char">'c'</span><span class="special">,</span>
|
||
|
<span class="char">'d'</span> <span class="special">}</span></code>.
|
||
|
</p>
|
||
|
<h5>
|
||
|
<a name="asio.reference.buffer.h4"></a>
|
||
|
<span><a name="asio.reference.buffer.buffers_and_scatter_gather_i_o"></a></span><a class="link" href="buffer.html#asio.reference.buffer.buffers_and_scatter_gather_i_o">Buffers and
|
||
|
Scatter-Gather I/O</a>
|
||
|
</h5>
|
||
|
<p>
|
||
|
To read or write using multiple buffers (i.e. scatter-gather I/O), multiple
|
||
|
buffer objects may be assigned into a container that supports the MutableBufferSequence
|
||
|
(for read) or ConstBufferSequence (for write) concepts:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">char</span> <span class="identifier">d1</span><span class="special">[</span><span class="number">128</span><span class="special">];</span>
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">char</span><span class="special">></span> <span class="identifier">d2</span><span class="special">(</span><span class="number">128</span><span class="special">);</span>
|
||
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span><span class="keyword">char</span><span class="special">,</span> <span class="number">128</span><span class="special">></span> <span class="identifier">d3</span><span class="special">;</span>
|
||
|
|
||
|
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span><span class="identifier">mutable_buffer</span><span class="special">,</span> <span class="number">3</span><span class="special">></span> <span class="identifier">bufs1</span> <span class="special">=</span> <span class="special">{</span>
|
||
|
<span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">d1</span><span class="special">),</span>
|
||
|
<span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">d2</span><span class="special">),</span>
|
||
|
<span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">d3</span><span class="special">)</span> <span class="special">};</span>
|
||
|
<span class="identifier">bytes_transferred</span> <span class="special">=</span> <span class="identifier">sock</span><span class="special">.</span><span class="identifier">receive</span><span class="special">(</span><span class="identifier">bufs1</span><span class="special">);</span>
|
||
|
|
||
|
<span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="identifier">const_buffer</span><span class="special">></span> <span class="identifier">bufs2</span><span class="special">;</span>
|
||
|
<span class="identifier">bufs2</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">d1</span><span class="special">));</span>
|
||
|
<span class="identifier">bufs2</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">d2</span><span class="special">));</span>
|
||
|
<span class="identifier">bufs2</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer</span><span class="special">(</span><span class="identifier">d3</span><span class="special">));</span>
|
||
|
<span class="identifier">bytes_transferred</span> <span class="special">=</span> <span class="identifier">sock</span><span class="special">.</span><span class="identifier">send</span><span class="special">(</span><span class="identifier">bufs2</span><span class="special">);</span>
|
||
|
</pre>
|
||
|
<h5>
|
||
|
<a name="asio.reference.buffer.h5"></a>
|
||
|
<span><a name="asio.reference.buffer.buffer_literals"></a></span><a class="link" href="buffer.html#asio.reference.buffer.buffer_literals">Buffer
|
||
|
Literals</a>
|
||
|
</h5>
|
||
|
<p>
|
||
|
The <code class="computeroutput"><span class="special">\</span><span class="identifier">_buf</span></code>
|
||
|
literal suffix, defined in namespace <code class="computeroutput"><span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer_literals</span></code>,
|
||
|
may be used to create <code class="computeroutput"><span class="identifier">const_buffer</span></code>
|
||
|
objects from string, binary integer, and hexadecimal integer literals. For
|
||
|
example:
|
||
|
</p>
|
||
|
<pre class="programlisting"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">asio</span><span class="special">::</span><span class="identifier">buffer_literals</span><span class="special">;</span>
|
||
|
|
||
|
<span class="identifier">asio</span><span class="special">::</span><span class="identifier">const_buffer</span> <span class="identifier">b1</span> <span class="special">=</span> <span class="string">"hello"</span><span class="identifier">_buf</span><span class="special">;</span>
|
||
|
<span class="identifier">asio</span><span class="special">::</span><span class="identifier">const_buffer</span> <span class="identifier">b2</span> <span class="special">=</span> <span class="number">0xdeadbeef</span><span class="identifier">_buf</span><span class="special">;</span>
|
||
|
<span class="identifier">asio</span><span class="special">::</span><span class="identifier">const_buffer</span> <span class="identifier">b3</span> <span class="special">=</span> <span class="number">0</span><span class="identifier">x0123456789abcdef0123456789abcdef_buf</span><span class="special">;</span>
|
||
|
<span class="identifier">asio</span><span class="special">::</span><span class="identifier">const_buffer</span> <span class="identifier">b4</span> <span class="special">=</span> <span class="number">0</span><span class="identifier">b1010101011001100_buf</span><span class="special">;</span>
|
||
|
</pre>
|
||
|
<p>
|
||
|
Note that the memory associated with a buffer literal is valid for the lifetime
|
||
|
of the program. This means that the buffer can be safely used with asynchronous
|
||
|
operations.
|
||
|
</p>
|
||
|
<h5>
|
||
|
<a name="asio.reference.buffer.h6"></a>
|
||
|
<span><a name="asio.reference.buffer.requirements"></a></span><a class="link" href="buffer.html#asio.reference.buffer.requirements">Requirements</a>
|
||
|
</h5>
|
||
|
<p>
|
||
|
<span class="emphasis"><em>Header: </em></span><code class="literal">asio/buffer.hpp</code>
|
||
|
</p>
|
||
|
<p>
|
||
|
<span class="emphasis"><em>Convenience header: </em></span><code class="literal">asio.hpp</code>
|
||
|
</p>
|
||
|
</div>
|
||
|
<div class="copyright-footer">Copyright © 2003-2023 Christopher M. Kohlhoff<p>
|
||
|
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||
|
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>)
|
||
|
</p>
|
||
|
</div>
|
||
|
<hr>
|
||
|
<div class="spirit-nav">
|
||
|
<a accesskey="p" href="bind_immediate_executor.html"><img src="../../prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../home.png" alt="Home"></a><a accesskey="n" href="buffer/overload1.html"><img src="../../next.png" alt="Next"></a>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|