1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>use_future_t</title> 5<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../boost_asio.html" title="Boost.Asio"> 8<link rel="up" href="../reference.html" title="Reference"> 9<link rel="prev" href="use_future.html" title="use_future"> 10<link rel="next" href="use_future_t/allocator_type.html" title="use_future_t::allocator_type"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td> 15<td align="center"><a href="../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="use_future.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="use_future_t/allocator_type.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h3 class="title"> 27<a name="boost_asio.reference.use_future_t"></a><a class="link" href="use_future_t.html" title="use_future_t">use_future_t</a> 28</h3></div></div></div> 29<p> 30 Class used to specify that an asynchronous operation should return a future. 31 </p> 32<pre class="programlisting">template< 33 typename Allocator = std::allocator<void>> 34class use_future_t 35</pre> 36<h5> 37<a name="boost_asio.reference.use_future_t.h0"></a> 38 <span class="phrase"><a name="boost_asio.reference.use_future_t.types"></a></span><a class="link" href="use_future_t.html#boost_asio.reference.use_future_t.types">Types</a> 39 </h5> 40<div class="informaltable"><table class="table"> 41<colgroup> 42<col> 43<col> 44</colgroup> 45<thead><tr> 46<th> 47 <p> 48 Name 49 </p> 50 </th> 51<th> 52 <p> 53 Description 54 </p> 55 </th> 56</tr></thead> 57<tbody><tr> 58<td> 59 <p> 60 <a class="link" href="use_future_t/allocator_type.html" title="use_future_t::allocator_type"><span class="bold"><strong>allocator_type</strong></span></a> 61 </p> 62 </td> 63<td> 64 <p> 65 The allocator type. The allocator is used when constructing the 66 std::promise object for a given asynchronous operation. 67 </p> 68 </td> 69</tr></tbody> 70</table></div> 71<h5> 72<a name="boost_asio.reference.use_future_t.h1"></a> 73 <span class="phrase"><a name="boost_asio.reference.use_future_t.member_functions"></a></span><a class="link" href="use_future_t.html#boost_asio.reference.use_future_t.member_functions">Member 74 Functions</a> 75 </h5> 76<div class="informaltable"><table class="table"> 77<colgroup> 78<col> 79<col> 80</colgroup> 81<thead><tr> 82<th> 83 <p> 84 Name 85 </p> 86 </th> 87<th> 88 <p> 89 Description 90 </p> 91 </th> 92</tr></thead> 93<tbody> 94<tr> 95<td> 96 <p> 97 <a class="link" href="use_future_t/get_allocator.html" title="use_future_t::get_allocator"><span class="bold"><strong>get_allocator</strong></span></a> 98 </p> 99 </td> 100<td> 101 <p> 102 Obtain allocator. 103 </p> 104 </td> 105</tr> 106<tr> 107<td> 108 <p> 109 <a class="link" href="use_future_t/operator_lp__rp_.html" title="use_future_t::operator()"><span class="bold"><strong>operator()</strong></span></a> 110 </p> 111 </td> 112<td> 113 <p> 114 Wrap a function object in a packaged task. 115 </p> 116 </td> 117</tr> 118<tr> 119<td> 120 <p> 121 <a class="link" href="use_future_t/operator_lb__rb_.html" title="use_future_t::operator[]"><span class="bold"><strong>operator[]</strong></span></a> 122 </p> 123 </td> 124<td> 125 <p> 126 (Deprecated: Use rebind().) Specify an alternate allocator. 127 </p> 128 </td> 129</tr> 130<tr> 131<td> 132 <p> 133 <a class="link" href="use_future_t/rebind.html" title="use_future_t::rebind"><span class="bold"><strong>rebind</strong></span></a> 134 </p> 135 </td> 136<td> 137 <p> 138 Specify an alternate allocator. 139 </p> 140 </td> 141</tr> 142<tr> 143<td> 144 <p> 145 <a class="link" href="use_future_t/use_future_t.html" title="use_future_t::use_future_t"><span class="bold"><strong>use_future_t</strong></span></a> <span class="silver">[constructor]</span> 146 </p> 147 </td> 148<td> 149 <p> 150 Construct using default-constructed allocator. <br> <span class="silver"> —</span><br> Construct 151 using specified allocator. 152 </p> 153 </td> 154</tr> 155</tbody> 156</table></div> 157<p> 158 The <a class="link" href="use_future_t.html" title="use_future_t"><code class="computeroutput">use_future_t</code></a> 159 class is used to indicate that an asynchronous operation should return a 160 std::future object. A <a class="link" href="use_future_t.html" title="use_future_t"><code class="computeroutput">use_future_t</code></a> 161 object may be passed as a handler to an asynchronous operation, typically 162 using the special value <code class="computeroutput">boost::asio::use_future</code>. For example: 163 </p> 164<pre class="programlisting">std::future<std::size_t> my_future 165 = my_socket.async_read_some(my_buffer, boost::asio::use_future); 166</pre> 167<p> 168 The initiating function (async_read_some in the above example) returns a 169 future that will receive the result of the operation. If the operation completes 170 with an error_code indicating failure, it is converted into a system_error 171 and passed back to the caller via the future. 172 </p> 173<h5> 174<a name="boost_asio.reference.use_future_t.h2"></a> 175 <span class="phrase"><a name="boost_asio.reference.use_future_t.requirements"></a></span><a class="link" href="use_future_t.html#boost_asio.reference.use_future_t.requirements">Requirements</a> 176 </h5> 177<p> 178 <span class="emphasis"><em>Header: </em></span><code class="literal">boost/asio/use_future.hpp</code> 179 </p> 180<p> 181 <span class="emphasis"><em>Convenience header: </em></span><code class="literal">boost/asio.hpp</code> 182 </p> 183</div> 184<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 185<td align="left"></td> 186<td align="right"><div class="copyright-footer">Copyright © 2003-2020 Christopher M. 187 Kohlhoff<p> 188 Distributed under the Boost Software License, Version 1.0. (See accompanying 189 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>) 190 </p> 191</div></td> 192</tr></table> 193<hr> 194<div class="spirit-nav"> 195<a accesskey="p" href="use_future.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../reference.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="use_future_t/allocator_type.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a> 196</div> 197</body> 198</html> 199