Skip to content

Commit

Permalink
Fix overloads that are ambiguous when using default completion tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskohlhoff authored and ashtum committed Jun 27, 2024
1 parent ee9762e commit 1a2b85b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
24 changes: 22 additions & 2 deletions include/boost/beast/core/basic_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,10 @@ class basic_stream
,class = typename std::enable_if<
net::is_endpoint_sequence<
EndpointSequence>::value>::type
,class = typename std::enable_if<
!net::is_connect_condition<RangeConnectHandler,
decltype(std::declval<const EndpointSequence&>().begin())>::value
>::type
#endif
>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
Expand Down Expand Up @@ -1132,6 +1136,10 @@ class basic_stream
,class = typename std::enable_if<
net::is_endpoint_sequence<
EndpointSequence>::value>::type
,class = typename std::enable_if<
net::is_connect_condition<ConnectCondition,
decltype(std::declval<const EndpointSequence&>().begin())>::value
>::type
#endif
>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
Expand Down Expand Up @@ -1204,7 +1212,13 @@ class basic_stream
BOOST_ASIO_COMPLETION_TOKEN_FOR(
void(error_code, Iterator))
IteratorConnectHandler =
net::default_completion_token_t<executor_type>>
net::default_completion_token_t<executor_type>
#if ! BOOST_BEAST_DOXYGEN
,class = typename std::enable_if<
!net::is_connect_condition<IteratorConnectHandler, Iterator>::value
>::type
#endif
>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
IteratorConnectHandler,
void(error_code, Iterator))
Expand Down Expand Up @@ -1278,7 +1292,13 @@ class basic_stream
BOOST_ASIO_COMPLETION_TOKEN_FOR(
void(error_code, Iterator))
IteratorConnectHandler =
net::default_completion_token_t<executor_type>>
net::default_completion_token_t<executor_type>
#if ! BOOST_BEAST_DOXYGEN
,class = typename std::enable_if<
net::is_connect_condition<ConnectCondition, Iterator>::value
>::type
#endif
>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
IteratorConnectHandler,
void(error_code, Iterator))
Expand Down
8 changes: 6 additions & 2 deletions include/boost/beast/core/impl/basic_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ template<class Protocol, class Executor, class RatePolicy>
template<
class EndpointSequence,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, typename Protocol::endpoint)) RangeConnectHandler,
class,
class>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(RangeConnectHandler,void(error_code, typename Protocol::endpoint))
basic_stream<Protocol, Executor, RatePolicy>::
Expand All @@ -927,6 +928,7 @@ template<
class EndpointSequence,
class ConnectCondition,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, typename Protocol::endpoint)) RangeConnectHandler,
class,
class>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(RangeConnectHandler,void (error_code, typename Protocol::endpoint))
basic_stream<Protocol, Executor, RatePolicy>::
Expand All @@ -948,7 +950,8 @@ async_connect(
template<class Protocol, class Executor, class RatePolicy>
template<
class Iterator,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, Iterator)) IteratorConnectHandler>
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, Iterator)) IteratorConnectHandler,
class>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(IteratorConnectHandler,void (error_code, Iterator))
basic_stream<Protocol, Executor, RatePolicy>::
async_connect(
Expand All @@ -969,7 +972,8 @@ template<class Protocol, class Executor, class RatePolicy>
template<
class Iterator,
class ConnectCondition,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, Iterator)) IteratorConnectHandler>
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, Iterator)) IteratorConnectHandler,
class>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(IteratorConnectHandler,void (error_code, Iterator))
basic_stream<Protocol, Executor, RatePolicy>::
async_connect(
Expand Down
9 changes: 8 additions & 1 deletion include/boost/beast/websocket/impl/accept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,11 @@ template<
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)
stream<NextLayer, deflateSupported>::
async_accept(
AcceptHandler&& handler)
AcceptHandler&& handler,
typename std::enable_if<
! net::is_const_buffer_sequence<
AcceptHandler>::value>::type*
)
{
static_assert(is_async_stream<next_layer_type>::value,
"AsyncStream type requirements not met");
Expand All @@ -627,6 +631,9 @@ stream<NextLayer, deflateSupported>::
async_accept(
ConstBufferSequence const& buffers,
AcceptHandler&& handler,
typename std::enable_if<
net::is_const_buffer_sequence<
ConstBufferSequence>::value>::type*,
typename std::enable_if<
! http::detail::is_header<
ConstBufferSequence>::value>::type*
Expand Down
11 changes: 10 additions & 1 deletion include/boost/beast/websocket/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,13 @@ class stream
async_accept(
AcceptHandler&& handler =
net::default_completion_token_t<
executor_type>{});
executor_type>{}
#ifndef BOOST_BEAST_DOXYGEN
, typename std::enable_if<
! net::is_const_buffer_sequence<
AcceptHandler>::value>::type* = nullptr
#endif
);

/** Perform the WebSocket handshake asynchronously in the server role.
Expand Down Expand Up @@ -1454,6 +1460,9 @@ class stream
net::default_completion_token_t<
executor_type>{}
#ifndef BOOST_BEAST_DOXYGEN
, typename std::enable_if<
net::is_const_buffer_sequence<
ConstBufferSequence>::value>::type* = 0
, typename std::enable_if<
! http::detail::is_header<
ConstBufferSequence>::value>::type* = 0
Expand Down

0 comments on commit 1a2b85b

Please sign in to comment.