Adds asio library and Storage Module
This commit is contained in:
1 parent
79a6ee5779
commit
30439acd43
4869 files changed
+618801
-903
No files matched your search
@@ -0,0 +1,63 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Array Container</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="../cpp2011.html" title="C++ 2011 Support">
|
||||
<link rel="prev" href="variadic.html" title="Variadic Templates">
|
||||
<link rel="next" href="atomic.html" title="Atomics">
|
||||
</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="variadic.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="atomic.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.cpp2011.array"></a><a class="link" href="array.html" title="Array Container">Array Container</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Where the standard library provides <code class="computeroutput">std::array<></code>, Asio:
|
||||
</p>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
|
||||
<li class="listitem">
|
||||
Provides overloads for the <a class="link" href="../../reference/buffer.html" title="buffer">buffer()</a>
|
||||
function.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Uses it in preference to <code class="computeroutput">boost::array<></code> for the
|
||||
<a class="link" href="../../reference/ip__address_v4/bytes_type.html" title="ip::address_v4::bytes_type">ip::address_v4::bytes_type</a>
|
||||
and <a class="link" href="../../reference/ip__address_v6/bytes_type.html" title="ip::address_v6::bytes_type">ip::address_v6::bytes_type</a>
|
||||
types.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Uses it in preference to <code class="computeroutput">boost::array<></code> where a
|
||||
fixed size array type is needed in the implementation.
|
||||
</li>
|
||||
</ul></div>
|
||||
<p>
|
||||
Support for <code class="computeroutput">std::array<></code> is automatically enabled for
|
||||
<code class="literal">g++</code> 4.3 and later, when the <code class="literal">-std=c++0x</code>
|
||||
or <code class="literal">-std=gnu++0x</code> compiler options are used, as well as
|
||||
for Microsoft Visual C++ 10. It may be disabled by defining <code class="computeroutput">ASIO_DISABLE_STD_ARRAY</code>,
|
||||
or explicitly enabled for other compilers by defining <code class="computeroutput">ASIO_HAS_STD_ARRAY</code>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 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></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="variadic.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="atomic.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,48 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Atomics</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="../cpp2011.html" title="C++ 2011 Support">
|
||||
<link rel="prev" href="array.html" title="Array Container">
|
||||
<link rel="next" href="shared_ptr.html" title="Shared Pointers">
|
||||
</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="array.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="shared_ptr.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.cpp2011.atomic"></a><a class="link" href="atomic.html" title="Atomics">Atomics</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Asio's implementation can use <code class="computeroutput">std::atomic<></code> in preference
|
||||
to <code class="computeroutput">boost::detail::atomic_count</code>.
|
||||
</p>
|
||||
<p>
|
||||
Support for the standard atomic integer template is automatically enabled
|
||||
for <code class="literal">g++</code> 4.5 and later, when the <code class="literal">-std=c++0x</code>
|
||||
or <code class="literal">-std=gnu++0x</code> compiler options are used. It may be
|
||||
disabled by defining <code class="computeroutput">ASIO_DISABLE_STD_ATOMIC</code>, or explicitly
|
||||
enabled for other compilers by defining <code class="computeroutput">ASIO_HAS_STD_ATOMIC</code>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 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></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="array.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="shared_ptr.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,59 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Chrono</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="../cpp2011.html" title="C++ 2011 Support">
|
||||
<link rel="prev" href="shared_ptr.html" title="Shared Pointers">
|
||||
<link rel="next" href="futures.html" title="Futures">
|
||||
</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="shared_ptr.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="futures.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.cpp2011.chrono"></a><a class="link" href="chrono.html" title="Chrono">Chrono</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Asio provides timers based on the <code class="computeroutput">std::chrono</code> facilities via
|
||||
the <a class="link" href="../../reference/basic_waitable_timer.html" title="basic_waitable_timer">basic_waitable_timer</a>
|
||||
class template. The typedefs <a class="link" href="../../reference/system_timer.html" title="system_timer">system_timer</a>,
|
||||
<a class="link" href="../../reference/steady_timer.html" title="steady_timer">steady_timer</a> and <a class="link" href="../../reference/high_resolution_timer.html" title="high_resolution_timer">high_resolution_timer</a>
|
||||
utilise the standard clocks <code class="computeroutput">system_clock</code>, <code class="computeroutput">steady_clock</code>
|
||||
and <code class="computeroutput">high_resolution_clock</code> respectively.
|
||||
</p>
|
||||
<p>
|
||||
Support for the <code class="computeroutput">std::chrono</code> facilities is automatically enabled
|
||||
for <code class="literal">g++</code> 4.6 and later, when the <code class="literal">-std=c++0x</code>
|
||||
or <code class="literal">-std=gnu++0x</code> compiler options are used. (Note that,
|
||||
for <code class="literal">g++</code>, the draft-standard <code class="computeroutput">monotonic_clock</code>
|
||||
is used in place of <code class="computeroutput">steady_clock</code>.) Support may be disabled
|
||||
by defining <code class="computeroutput">ASIO_DISABLE_STD_CHRONO</code>, or explicitly enabled
|
||||
for other compilers by defining <code class="computeroutput">ASIO_HAS_STD_CHRONO</code>.
|
||||
</p>
|
||||
<p>
|
||||
When standard <code class="computeroutput">chrono</code> is unavailable, Asio will otherwise use
|
||||
the Boost.Chrono library. The <a class="link" href="../../reference/basic_waitable_timer.html" title="basic_waitable_timer">basic_waitable_timer</a>
|
||||
class template may be used with either.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 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></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="shared_ptr.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="futures.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,75 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Futures</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="../cpp2011.html" title="C++ 2011 Support">
|
||||
<link rel="prev" href="chrono.html" title="Chrono">
|
||||
<link rel="next" href="../implementation.html" title="Platform-Specific Implementation Notes">
|
||||
</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="chrono.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="../implementation.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.cpp2011.futures"></a><a class="link" href="futures.html" title="Futures">Futures</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
The <code class="computeroutput">asio::use_future</code> special value provides first-class support
|
||||
for returning a C++11 <code class="computeroutput">std::future</code> from an asynchronous operation's
|
||||
initiating function.
|
||||
</p>
|
||||
<p>
|
||||
To use <code class="computeroutput">asio::use_future</code>, pass it to an asynchronous operation
|
||||
instead of a normal completion handler. For example:
|
||||
</p>
|
||||
<pre class="programlisting">std::future<std::size_t> length =
|
||||
my_socket.async_read_some(my_buffer, asio::use_future);
|
||||
</pre>
|
||||
<p>
|
||||
Where a handler signature has the form:
|
||||
</p>
|
||||
<pre class="programlisting">void handler(asio::error_code ec, result_type result);
|
||||
</pre>
|
||||
<p>
|
||||
the initiating function returns a <code class="computeroutput">std::future</code> templated on
|
||||
<code class="computeroutput">result_type</code>. In the above example, this is <code class="computeroutput">std::size_t</code>.
|
||||
If the asynchronous operation fails, the <code class="computeroutput">error_code</code> is converted
|
||||
into a <code class="computeroutput">system_error</code> exception and passed back to the caller
|
||||
through the future.
|
||||
</p>
|
||||
<p>
|
||||
Where a handler signature has the form:
|
||||
</p>
|
||||
<pre class="programlisting">void handler(asio::error_code ec);
|
||||
</pre>
|
||||
<p>
|
||||
the initiating function returns <code class="computeroutput">std::future<void></code>. As
|
||||
above, an error is passed back in the future as a <code class="computeroutput">system_error</code>
|
||||
exception.
|
||||
</p>
|
||||
<p>
|
||||
<a class="link" href="../../reference/use_future.html" title="use_future">use_future</a>, <a class="link" href="../../reference/use_future_t.html" title="use_future_t">use_future_t</a>,
|
||||
<a class="link" href="../../examples/cpp11_examples.html#asio.examples.cpp11_examples.futures">Futures example (C++11)</a>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 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></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="chrono.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="../implementation.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,81 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Movable Handlers</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="../cpp2011.html" title="C++ 2011 Support">
|
||||
<link rel="prev" href="move_objects.html" title="Movable I/O Objects">
|
||||
<link rel="next" href="variadic.html" title="Variadic Templates">
|
||||
</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="move_objects.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="variadic.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.cpp2011.move_handlers"></a><a class="link" href="move_handlers.html" title="Movable Handlers">Movable Handlers</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
With C++11 and later, user-defined completion handlers are only required
|
||||
to be move constructible, and are not required to be copy constructible.
|
||||
</p>
|
||||
<p>
|
||||
When move support is enabled, asynchronous that are documented as follows:
|
||||
</p>
|
||||
<pre class="programlisting">template <typename Handler>
|
||||
void async_XYZ(..., Handler handler);
|
||||
</pre>
|
||||
<p>
|
||||
are actually declared as:
|
||||
</p>
|
||||
<pre class="programlisting">template <typename Handler>
|
||||
void async_XYZ(..., Handler&& handler);
|
||||
</pre>
|
||||
<p>
|
||||
The handler argument is perfectly forwarded and the move construction occurs
|
||||
within the body of <code class="computeroutput">async_XYZ()</code>. This ensures that all other
|
||||
function arguments are evaluated prior to the move. This is critical when
|
||||
the other arguments to <code class="computeroutput">async_XYZ()</code> are members of the handler.
|
||||
For example:
|
||||
</p>
|
||||
<pre class="programlisting">struct my_operation
|
||||
{
|
||||
unique_ptr<tcp::socket> socket;
|
||||
unique_ptr<vector<char>> buffer;
|
||||
...
|
||||
void operator(error_code ec, size_t length)
|
||||
{
|
||||
...
|
||||
socket->async_read_some(asio::buffer(*buffer), std::move(*this));
|
||||
...
|
||||
}
|
||||
};
|
||||
</pre>
|
||||
<p>
|
||||
Move support is automatically enabled for <code class="literal">g++</code> 4.5 and
|
||||
later, when the <code class="literal">-std=c++0x</code> or <code class="literal">-std=gnu++0x</code>
|
||||
compiler options are used. It may be disabled by defining <code class="computeroutput">ASIO_DISABLE_MOVE</code>,
|
||||
or explicitly enabled for other compilers by defining <code class="computeroutput">ASIO_HAS_MOVE</code>.
|
||||
Note that these macros also affect the availability of <a class="link" href="move_objects.html" title="Movable I/O Objects">movable
|
||||
I/O objects</a>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 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></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="move_objects.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="variadic.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,102 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Movable I/O Objects</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="../cpp2011.html" title="C++ 2011 Support">
|
||||
<link rel="prev" href="system_error.html" title="System Errors and Error Codes">
|
||||
<link rel="next" href="move_handlers.html" title="Movable Handlers">
|
||||
</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="system_error.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="move_handlers.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.cpp2011.move_objects"></a><a class="link" href="move_objects.html" title="Movable I/O Objects">Movable I/O Objects</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
When move support is available (via rvalue references), Asio allows move
|
||||
construction and assignment of sockets, serial ports, POSIX descriptors
|
||||
and Windows handles.
|
||||
</p>
|
||||
<p>
|
||||
Move support allows you to write code like:
|
||||
</p>
|
||||
<pre class="programlisting">tcp::socket make_socket(io_context& i)
|
||||
{
|
||||
tcp::socket s(i);
|
||||
...
|
||||
std::move(s);
|
||||
}
|
||||
</pre>
|
||||
<p>
|
||||
or:
|
||||
</p>
|
||||
<pre class="programlisting">class connection : public enable_shared_from_this<connection>
|
||||
{
|
||||
private:
|
||||
tcp::socket socket_;
|
||||
...
|
||||
public:
|
||||
connection(tcp::socket&& s) : socket_(std::move(s)) {}
|
||||
...
|
||||
};
|
||||
|
||||
...
|
||||
|
||||
class server
|
||||
{
|
||||
private:
|
||||
tcp::acceptor acceptor_;
|
||||
...
|
||||
void handle_accept(error_code ec, tcp::socket socket)
|
||||
{
|
||||
if (!ec)
|
||||
std::make_shared<connection>(std::move(socket))->go();
|
||||
acceptor_.async_accept(...);
|
||||
}
|
||||
...
|
||||
};
|
||||
</pre>
|
||||
<p>
|
||||
as well as:
|
||||
</p>
|
||||
<pre class="programlisting">std::vector<tcp::socket> sockets;
|
||||
sockets.push_back(tcp::socket(...));
|
||||
</pre>
|
||||
<p>
|
||||
A word of warning: There is nothing stopping you from moving these objects
|
||||
while there are pending asynchronous operations, but it is unlikely to
|
||||
be a good idea to do so. In particular, composed operations like <a class="link" href="../../reference/async_read.html" title="async_read">async_read()</a> store a reference
|
||||
to the stream object. Moving during the composed operation means that the
|
||||
composed operation may attempt to access a moved-from object.
|
||||
</p>
|
||||
<p>
|
||||
Move support is automatically enabled for <code class="literal">g++</code> 4.5 and
|
||||
later, when the <code class="literal">-std=c++0x</code> or <code class="literal">-std=gnu++0x</code>
|
||||
compiler options are used. It may be disabled by defining <code class="computeroutput">ASIO_DISABLE_MOVE</code>,
|
||||
or explicitly enabled for other compilers by defining <code class="computeroutput">ASIO_HAS_MOVE</code>.
|
||||
Note that these macros also affect the availability of <a class="link" href="move_handlers.html" title="Movable Handlers">movable
|
||||
handlers</a>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 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></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="system_error.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="move_handlers.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,48 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Shared Pointers</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="../cpp2011.html" title="C++ 2011 Support">
|
||||
<link rel="prev" href="atomic.html" title="Atomics">
|
||||
<link rel="next" href="chrono.html" title="Chrono">
|
||||
</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="atomic.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="chrono.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.cpp2011.shared_ptr"></a><a class="link" href="shared_ptr.html" title="Shared Pointers">Shared Pointers</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
Asio's implementation can use <code class="computeroutput">std::shared_ptr<></code> and
|
||||
<code class="computeroutput">std::weak_ptr<></code> in preference to the Boost equivalents.
|
||||
</p>
|
||||
<p>
|
||||
Support for the standard smart pointers is automatically enabled for <code class="literal">g++</code>
|
||||
4.3 and later, when the <code class="literal">-std=c++0x</code> or <code class="literal">-std=gnu++0x</code>
|
||||
compiler options are used, as well as for Microsoft Visual C++ 10. It may
|
||||
be disabled by defining <code class="computeroutput">ASIO_DISABLE_STD_SHARED_PTR</code>, or explicitly
|
||||
enabled for other compilers by defining <code class="computeroutput">ASIO_HAS_STD_SHARED_PTR</code>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 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></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="atomic.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="chrono.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,50 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>System Errors and Error Codes</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="../cpp2011.html" title="C++ 2011 Support">
|
||||
<link rel="prev" href="../cpp2011.html" title="C++ 2011 Support">
|
||||
<link rel="next" href="move_objects.html" title="Movable I/O Objects">
|
||||
</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="../cpp2011.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="move_objects.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.cpp2011.system_error"></a><a class="link" href="system_error.html" title="System Errors and Error Codes">System Errors and
|
||||
Error Codes</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
When available, Asio can use the <code class="computeroutput">std::error_code</code> and <code class="computeroutput">std::system_error</code>
|
||||
classes for reporting errors. In this case, the names <code class="computeroutput">asio::error_code</code>
|
||||
and <code class="computeroutput">asio::system_error</code> will be typedefs for these standard
|
||||
classes.
|
||||
</p>
|
||||
<p>
|
||||
System error support is automatically enabled for <code class="literal">g++</code>
|
||||
4.6 and later, when the <code class="literal">-std=c++0x</code> or <code class="literal">-std=gnu++0x</code>
|
||||
compiler options are used. It may be disabled by defining <code class="computeroutput">ASIO_DISABLE_STD_SYSTEM_ERROR</code>,
|
||||
or explicitly enabled for other compilers by defining <code class="computeroutput">ASIO_HAS_STD_SYSTEM_ERROR</code>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 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></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="../cpp2011.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="move_objects.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,49 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Variadic Templates</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="../cpp2011.html" title="C++ 2011 Support">
|
||||
<link rel="prev" href="move_handlers.html" title="Movable Handlers">
|
||||
<link rel="next" href="array.html" title="Array Container">
|
||||
</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="move_handlers.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="array.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
<div class="section">
|
||||
<div class="titlepage"><div><div><h4 class="title">
|
||||
<a name="asio.overview.cpp2011.variadic"></a><a class="link" href="variadic.html" title="Variadic Templates">Variadic Templates</a>
|
||||
</h4></div></div></div>
|
||||
<p>
|
||||
When supported by a compiler, Asio can use variadic templates to implement
|
||||
the <a class="link" href="../../reference/basic_socket_streambuf/connect.html" title="basic_socket_streambuf::connect">basic_socket_streambuf::connect()</a>
|
||||
and <a class="link" href="../../reference/basic_socket_iostream/connect.html" title="basic_socket_iostream::connect">basic_socket_iostream::connect()</a>
|
||||
functions.
|
||||
</p>
|
||||
<p>
|
||||
Support for variadic templates is automatically enabled for <code class="literal">g++</code>
|
||||
4.3 and later, when the <code class="literal">-std=c++0x</code> or <code class="literal">-std=gnu++0x</code>
|
||||
compiler options are used. It may be disabled by defining <code class="computeroutput">ASIO_DISABLE_VARIADIC_TEMPLATES</code>,
|
||||
or explicitly enabled for other compilers by defining <code class="computeroutput">ASIO_HAS_VARIADIC_TEMPLATES</code>.
|
||||
</p>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"></td>
|
||||
<td align="right"><div class="copyright-footer">Copyright © 2003-2020 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></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
<div class="spirit-nav">
|
||||
<a accesskey="p" href="move_handlers.html"><img src="../../../prev.png" alt="Prev"></a><a accesskey="u" href="../cpp2011.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="array.html"><img src="../../../next.png" alt="Next"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user