mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +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
|
||||
* Add basic_stream::rebind_executor
|
||||
* Use automatically deduced return types for all async operations
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -1125,7 +1125,9 @@ public:
|
||||
class Iterator,
|
||||
class IteratorConnectHandler =
|
||||
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(
|
||||
Iterator begin, Iterator end,
|
||||
IteratorConnectHandler&& handler =
|
||||
@ -1182,7 +1184,9 @@ public:
|
||||
class ConnectCondition,
|
||||
class IteratorConnectHandler =
|
||||
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(
|
||||
Iterator begin, Iterator end,
|
||||
ConnectCondition connect_condition,
|
||||
|
@ -85,12 +85,12 @@ namespace net = boost::asio;
|
||||
|
||||
#ifndef BOOST_BEAST_ASYNC_RESULT1
|
||||
#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
|
||||
|
||||
#ifndef BOOST_BEAST_ASYNC_RESULT2
|
||||
#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
|
||||
|
@ -802,13 +802,13 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
typename std::enable_if<
|
||||
is_mutable_body_writer<Body>::value,
|
||||
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)>::type
|
||||
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)
|
||||
async_write(
|
||||
AsyncWriteStream& stream,
|
||||
message<isRequest, Body, Fields>& msg,
|
||||
WriteHandler&& handler)
|
||||
WriteHandler&& handler,
|
||||
typename std::enable_if<
|
||||
is_mutable_body_writer<Body>::value>::type*)
|
||||
{
|
||||
static_assert(
|
||||
is_async_write_stream<AsyncWriteStream>::value,
|
||||
@ -831,13 +831,13 @@ template<
|
||||
class AsyncWriteStream,
|
||||
bool isRequest, class Body, class Fields,
|
||||
class WriteHandler>
|
||||
typename std::enable_if<
|
||||
! is_mutable_body_writer<Body>::value,
|
||||
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)>::type
|
||||
BOOST_BEAST_ASYNC_RESULT2(WriteHandler)
|
||||
async_write(
|
||||
AsyncWriteStream& stream,
|
||||
message<isRequest, Body, Fields> const& msg,
|
||||
WriteHandler&& handler)
|
||||
WriteHandler&& handler,
|
||||
typename std::enable_if<
|
||||
! is_mutable_body_writer<Body>::value>::type*)
|
||||
{
|
||||
static_assert(
|
||||
is_async_write_stream<AsyncWriteStream>::value,
|
||||
|
@ -645,19 +645,18 @@ template<
|
||||
class WriteHandler =
|
||||
net::default_completion_token_t<
|
||||
executor_type<AsyncWriteStream>>>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
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(
|
||||
AsyncWriteStream& stream,
|
||||
message<isRequest, Body, Fields>& msg,
|
||||
WriteHandler&& handler =
|
||||
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.
|
||||
|
||||
@ -708,19 +707,19 @@ template<
|
||||
class WriteHandler =
|
||||
net::default_completion_token_t<
|
||||
executor_type<AsyncWriteStream>>>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
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(
|
||||
AsyncWriteStream& stream,
|
||||
message<isRequest, Body, Fields> const& msg,
|
||||
WriteHandler&& handler =
|
||||
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<
|
||||
class ConstBufferSequence,
|
||||
class AcceptHandler>
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<ConstBufferSequence>::value,
|
||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)>::type
|
||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)
|
||||
stream<NextLayer, deflateSupported>::
|
||||
async_accept(
|
||||
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,
|
||||
"AsyncStream type requirements not met");
|
||||
@ -620,14 +622,15 @@ template<
|
||||
class ConstBufferSequence,
|
||||
class ResponseDecorator,
|
||||
class AcceptHandler>
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<ConstBufferSequence>::value,
|
||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)>::type
|
||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)
|
||||
stream<NextLayer, deflateSupported>::
|
||||
async_accept_ex(
|
||||
ConstBufferSequence const& buffers,
|
||||
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,
|
||||
"AsyncStream type requirements not met");
|
||||
|
@ -1357,18 +1357,18 @@ public:
|
||||
class AcceptHandler =
|
||||
net::default_completion_token_t<executor_type>
|
||||
>
|
||||
#if BOOST_BEAST_DOXYGEN
|
||||
void_or_deduced
|
||||
#else
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<ConstBufferSequence>::value,
|
||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)>::type
|
||||
#endif
|
||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)
|
||||
async_accept(
|
||||
ConstBufferSequence const& buffers,
|
||||
AcceptHandler&& handler =
|
||||
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.
|
||||
|
||||
@ -2644,13 +2644,14 @@ public:
|
||||
class ConstBufferSequence,
|
||||
class ResponseDecorator,
|
||||
class AcceptHandler>
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<ConstBufferSequence>::value,
|
||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)>::type
|
||||
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)
|
||||
async_accept_ex(
|
||||
ConstBufferSequence const& buffers,
|
||||
ResponseDecorator const& decorator,
|
||||
AcceptHandler&& handler);
|
||||
AcceptHandler&& handler,
|
||||
typename std::enable_if<
|
||||
! http::detail::is_header<
|
||||
ConstBufferSequence>::value>::type* = 0);
|
||||
|
||||
template<
|
||||
class Body, class Allocator,
|
||||
|
@ -403,7 +403,8 @@ public:
|
||||
explicit fixture(std::size_t n, Strategy 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);
|
||||
zp.next_in = in.data();
|
||||
zp.avail_in = in.size();
|
||||
@ -479,8 +480,10 @@ public:
|
||||
// 125 will mostly fill the lit buffer, so emitting a distance code
|
||||
// results in a flush.
|
||||
auto constexpr n = 125;
|
||||
std::iota(in.begin(), in.begin() + n, 0);
|
||||
std::iota(in.begin() + n, in.end(), 0);
|
||||
std::iota(in.begin(), in.begin() + n,
|
||||
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);
|
||||
std::string out;
|
||||
|
Reference in New Issue
Block a user