mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 21:07:26 +02:00
Use automatically deduced return types for all async operations:
C++14 or later is required to support completion tokens that use per-operation return type deduction. For C++11, a completion token's async_result specialisation must still provide the nested typedef `return_type`.
This commit is contained in:
@ -2,6 +2,7 @@ Version 275:
|
|||||||
|
|
||||||
* Async init-fns use the executor's default token
|
* Async init-fns use the executor's default token
|
||||||
* Add basic_stream::rebind_executor
|
* Add basic_stream::rebind_executor
|
||||||
|
* Use automatically deduced return types for all async operations
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1125,7 +1125,9 @@ public:
|
|||||||
class Iterator,
|
class Iterator,
|
||||||
class IteratorConnectHandler =
|
class IteratorConnectHandler =
|
||||||
net::default_completion_token_t<executor_type>>
|
net::default_completion_token_t<executor_type>>
|
||||||
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,void (error_code, Iterator))
|
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||||
|
IteratorConnectHandler,
|
||||||
|
void(error_code, Iterator))
|
||||||
async_connect(
|
async_connect(
|
||||||
Iterator begin, Iterator end,
|
Iterator begin, Iterator end,
|
||||||
IteratorConnectHandler&& handler =
|
IteratorConnectHandler&& handler =
|
||||||
@ -1182,7 +1184,9 @@ public:
|
|||||||
class ConnectCondition,
|
class ConnectCondition,
|
||||||
class IteratorConnectHandler =
|
class IteratorConnectHandler =
|
||||||
net::default_completion_token_t<executor_type>>
|
net::default_completion_token_t<executor_type>>
|
||||||
BOOST_ASIO_INITFN_RESULT_TYPE(IteratorConnectHandler,void (error_code, Iterator))
|
BOOST_ASIO_INITFN_RESULT_TYPE(
|
||||||
|
IteratorConnectHandler,
|
||||||
|
void(error_code, Iterator))
|
||||||
async_connect(
|
async_connect(
|
||||||
Iterator begin, Iterator end,
|
Iterator begin, Iterator end,
|
||||||
ConnectCondition connect_condition,
|
ConnectCondition connect_condition,
|
||||||
|
@ -85,12 +85,12 @@ namespace net = boost::asio;
|
|||||||
|
|
||||||
#ifndef BOOST_BEAST_ASYNC_RESULT1
|
#ifndef BOOST_BEAST_ASYNC_RESULT1
|
||||||
#define BOOST_BEAST_ASYNC_RESULT1(type) \
|
#define BOOST_BEAST_ASYNC_RESULT1(type) \
|
||||||
BOOST_ASIO_INITFN_RESULT_TYPE(type, void(::boost::beast::error_code))
|
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(type, void(::boost::beast::error_code))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BOOST_BEAST_ASYNC_RESULT2
|
#ifndef BOOST_BEAST_ASYNC_RESULT2
|
||||||
#define BOOST_BEAST_ASYNC_RESULT2(type) \
|
#define BOOST_BEAST_ASYNC_RESULT2(type) \
|
||||||
BOOST_ASIO_INITFN_RESULT_TYPE(type, void(::boost::beast::error_code, std::size_t))
|
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(type, void(::boost::beast::error_code, std::size_t))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -802,13 +802,13 @@ template<
|
|||||||
class AsyncWriteStream,
|
class AsyncWriteStream,
|
||||||
bool isRequest, class Body, class Fields,
|
bool isRequest, class Body, class Fields,
|
||||||
class WriteHandler>
|
class WriteHandler>
|
||||||
typename std::enable_if<
|
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)
|
||||||
is_mutable_body_writer<Body>::value,
|
|
||||||
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)>::type
|
|
||||||
async_write(
|
async_write(
|
||||||
AsyncWriteStream& stream,
|
AsyncWriteStream& stream,
|
||||||
message<isRequest, Body, Fields>& msg,
|
message<isRequest, Body, Fields>& msg,
|
||||||
WriteHandler&& handler)
|
WriteHandler&& handler,
|
||||||
|
typename std::enable_if<
|
||||||
|
is_mutable_body_writer<Body>::value>::type*)
|
||||||
{
|
{
|
||||||
static_assert(
|
static_assert(
|
||||||
is_async_write_stream<AsyncWriteStream>::value,
|
is_async_write_stream<AsyncWriteStream>::value,
|
||||||
@ -831,13 +831,13 @@ template<
|
|||||||
class AsyncWriteStream,
|
class AsyncWriteStream,
|
||||||
bool isRequest, class Body, class Fields,
|
bool isRequest, class Body, class Fields,
|
||||||
class WriteHandler>
|
class WriteHandler>
|
||||||
typename std::enable_if<
|
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)
|
||||||
! is_mutable_body_writer<Body>::value,
|
|
||||||
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)>::type
|
|
||||||
async_write(
|
async_write(
|
||||||
AsyncWriteStream& stream,
|
AsyncWriteStream& stream,
|
||||||
message<isRequest, Body, Fields> const& msg,
|
message<isRequest, Body, Fields> const& msg,
|
||||||
WriteHandler&& handler)
|
WriteHandler&& handler,
|
||||||
|
typename std::enable_if<
|
||||||
|
! is_mutable_body_writer<Body>::value>::type*)
|
||||||
{
|
{
|
||||||
static_assert(
|
static_assert(
|
||||||
is_async_write_stream<AsyncWriteStream>::value,
|
is_async_write_stream<AsyncWriteStream>::value,
|
||||||
|
@ -645,19 +645,18 @@ template<
|
|||||||
class WriteHandler =
|
class WriteHandler =
|
||||||
net::default_completion_token_t<
|
net::default_completion_token_t<
|
||||||
executor_type<AsyncWriteStream>>>
|
executor_type<AsyncWriteStream>>>
|
||||||
#if BOOST_BEAST_DOXYGEN
|
|
||||||
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)
|
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)
|
||||||
#else
|
|
||||||
typename std::enable_if<
|
|
||||||
is_mutable_body_writer<Body>::value,
|
|
||||||
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)>::type
|
|
||||||
#endif
|
|
||||||
async_write(
|
async_write(
|
||||||
AsyncWriteStream& stream,
|
AsyncWriteStream& stream,
|
||||||
message<isRequest, Body, Fields>& msg,
|
message<isRequest, Body, Fields>& msg,
|
||||||
WriteHandler&& handler =
|
WriteHandler&& handler =
|
||||||
net::default_completion_token_t<
|
net::default_completion_token_t<
|
||||||
executor_type<AsyncWriteStream>>);
|
executor_type<AsyncWriteStream>>{}
|
||||||
|
#ifndef BOOST_BEAST_DOXYGEN
|
||||||
|
, typename std::enable_if<
|
||||||
|
is_mutable_body_writer<Body>::value>::type* = 0
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
/** Write a complete message to a stream asynchronously.
|
/** Write a complete message to a stream asynchronously.
|
||||||
|
|
||||||
@ -708,19 +707,19 @@ template<
|
|||||||
class WriteHandler =
|
class WriteHandler =
|
||||||
net::default_completion_token_t<
|
net::default_completion_token_t<
|
||||||
executor_type<AsyncWriteStream>>>
|
executor_type<AsyncWriteStream>>>
|
||||||
#if BOOST_BEAST_DOXYGEN
|
|
||||||
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)
|
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)
|
||||||
#else
|
|
||||||
typename std::enable_if<
|
|
||||||
! is_mutable_body_writer<Body>::value,
|
|
||||||
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)>::type
|
|
||||||
#endif
|
|
||||||
async_write(
|
async_write(
|
||||||
AsyncWriteStream& stream,
|
AsyncWriteStream& stream,
|
||||||
message<isRequest, Body, Fields> const& msg,
|
message<isRequest, Body, Fields> const& msg,
|
||||||
WriteHandler&& handler =
|
WriteHandler&& handler =
|
||||||
net::default_completion_token_t<
|
net::default_completion_token_t<
|
||||||
executor_type<AsyncWriteStream>>{});
|
executor_type<AsyncWriteStream>>{}
|
||||||
|
#ifndef BOOST_BEAST_DOXYGEN
|
||||||
|
, typename std::enable_if<
|
||||||
|
! is_mutable_body_writer<Body>::value>::type* = 0
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -591,13 +591,15 @@ template<class NextLayer, bool deflateSupported>
|
|||||||
template<
|
template<
|
||||||
class ConstBufferSequence,
|
class ConstBufferSequence,
|
||||||
class AcceptHandler>
|
class AcceptHandler>
|
||||||
typename std::enable_if<
|
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)
|
||||||
! http::detail::is_header<ConstBufferSequence>::value,
|
|
||||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)>::type
|
|
||||||
stream<NextLayer, deflateSupported>::
|
stream<NextLayer, deflateSupported>::
|
||||||
async_accept(
|
async_accept(
|
||||||
ConstBufferSequence const& buffers,
|
ConstBufferSequence const& buffers,
|
||||||
AcceptHandler&& handler)
|
AcceptHandler&& handler,
|
||||||
|
typename std::enable_if<
|
||||||
|
! http::detail::is_header<
|
||||||
|
ConstBufferSequence>::value>::type*
|
||||||
|
)
|
||||||
{
|
{
|
||||||
static_assert(is_async_stream<next_layer_type>::value,
|
static_assert(is_async_stream<next_layer_type>::value,
|
||||||
"AsyncStream type requirements not met");
|
"AsyncStream type requirements not met");
|
||||||
@ -620,14 +622,15 @@ template<
|
|||||||
class ConstBufferSequence,
|
class ConstBufferSequence,
|
||||||
class ResponseDecorator,
|
class ResponseDecorator,
|
||||||
class AcceptHandler>
|
class AcceptHandler>
|
||||||
typename std::enable_if<
|
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)
|
||||||
! http::detail::is_header<ConstBufferSequence>::value,
|
|
||||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)>::type
|
|
||||||
stream<NextLayer, deflateSupported>::
|
stream<NextLayer, deflateSupported>::
|
||||||
async_accept_ex(
|
async_accept_ex(
|
||||||
ConstBufferSequence const& buffers,
|
ConstBufferSequence const& buffers,
|
||||||
ResponseDecorator const& decorator,
|
ResponseDecorator const& decorator,
|
||||||
AcceptHandler&& handler)
|
AcceptHandler&& handler,
|
||||||
|
typename std::enable_if<
|
||||||
|
! http::detail::is_header<
|
||||||
|
ConstBufferSequence>::value>::type*)
|
||||||
{
|
{
|
||||||
static_assert(is_async_stream<next_layer_type>::value,
|
static_assert(is_async_stream<next_layer_type>::value,
|
||||||
"AsyncStream type requirements not met");
|
"AsyncStream type requirements not met");
|
||||||
|
@ -1357,18 +1357,18 @@ public:
|
|||||||
class AcceptHandler =
|
class AcceptHandler =
|
||||||
net::default_completion_token_t<executor_type>
|
net::default_completion_token_t<executor_type>
|
||||||
>
|
>
|
||||||
#if BOOST_BEAST_DOXYGEN
|
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)
|
||||||
void_or_deduced
|
|
||||||
#else
|
|
||||||
typename std::enable_if<
|
|
||||||
! http::detail::is_header<ConstBufferSequence>::value,
|
|
||||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)>::type
|
|
||||||
#endif
|
|
||||||
async_accept(
|
async_accept(
|
||||||
ConstBufferSequence const& buffers,
|
ConstBufferSequence const& buffers,
|
||||||
AcceptHandler&& handler =
|
AcceptHandler&& handler =
|
||||||
net::default_completion_token_t<
|
net::default_completion_token_t<
|
||||||
executor_type>{});
|
executor_type>{}
|
||||||
|
#ifndef BOOST_BEAST_DOXYGEN
|
||||||
|
, typename std::enable_if<
|
||||||
|
! http::detail::is_header<
|
||||||
|
ConstBufferSequence>::value>::type* = 0
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
/** Perform the WebSocket handshake asynchronously in the server role.
|
/** Perform the WebSocket handshake asynchronously in the server role.
|
||||||
|
|
||||||
@ -2644,13 +2644,14 @@ public:
|
|||||||
class ConstBufferSequence,
|
class ConstBufferSequence,
|
||||||
class ResponseDecorator,
|
class ResponseDecorator,
|
||||||
class AcceptHandler>
|
class AcceptHandler>
|
||||||
typename std::enable_if<
|
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)
|
||||||
! http::detail::is_header<ConstBufferSequence>::value,
|
|
||||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)>::type
|
|
||||||
async_accept_ex(
|
async_accept_ex(
|
||||||
ConstBufferSequence const& buffers,
|
ConstBufferSequence const& buffers,
|
||||||
ResponseDecorator const& decorator,
|
ResponseDecorator const& decorator,
|
||||||
AcceptHandler&& handler);
|
AcceptHandler&& handler,
|
||||||
|
typename std::enable_if<
|
||||||
|
! http::detail::is_header<
|
||||||
|
ConstBufferSequence>::value>::type* = 0);
|
||||||
|
|
||||||
template<
|
template<
|
||||||
class Body, class Allocator,
|
class Body, class Allocator,
|
||||||
|
@ -403,7 +403,8 @@ public:
|
|||||||
explicit fixture(std::size_t n, Strategy s)
|
explicit fixture(std::size_t n, Strategy s)
|
||||||
{
|
{
|
||||||
ds.reset(8, 15, 1, s);
|
ds.reset(8, 15, 1, s);
|
||||||
std::iota(in.begin(), in.end(), 0);
|
std::iota(in.begin(), in.end(),
|
||||||
|
static_cast<std::uint8_t>(0));
|
||||||
out.resize(n);
|
out.resize(n);
|
||||||
zp.next_in = in.data();
|
zp.next_in = in.data();
|
||||||
zp.avail_in = in.size();
|
zp.avail_in = in.size();
|
||||||
@ -479,8 +480,10 @@ public:
|
|||||||
// 125 will mostly fill the lit buffer, so emitting a distance code
|
// 125 will mostly fill the lit buffer, so emitting a distance code
|
||||||
// results in a flush.
|
// results in a flush.
|
||||||
auto constexpr n = 125;
|
auto constexpr n = 125;
|
||||||
std::iota(in.begin(), in.begin() + n, 0);
|
std::iota(in.begin(), in.begin() + n,
|
||||||
std::iota(in.begin() + n, in.end(), 0);
|
static_cast<std::uint8_t>(0));
|
||||||
|
std::iota(in.begin() + n, in.end(),
|
||||||
|
static_cast<std::uint8_t>(0));
|
||||||
|
|
||||||
ds.reset(8, 15, 1, Strategy::normal);
|
ds.reset(8, 15, 1, Strategy::normal);
|
||||||
std::string out;
|
std::string out;
|
||||||
|
Reference in New Issue
Block a user