Skip to content

Commit 1a2b85b

Browse files
chriskohlhoffashtum
authored andcommitted
Fix overloads that are ambiguous when using default completion tokens
1 parent ee9762e commit 1a2b85b

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

include/boost/beast/core/basic_stream.hpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,10 @@ class basic_stream
10261026
,class = typename std::enable_if<
10271027
net::is_endpoint_sequence<
10281028
EndpointSequence>::value>::type
1029+
,class = typename std::enable_if<
1030+
!net::is_connect_condition<RangeConnectHandler,
1031+
decltype(std::declval<const EndpointSequence&>().begin())>::value
1032+
>::type
10291033
#endif
10301034
>
10311035
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
@@ -1132,6 +1136,10 @@ class basic_stream
11321136
,class = typename std::enable_if<
11331137
net::is_endpoint_sequence<
11341138
EndpointSequence>::value>::type
1139+
,class = typename std::enable_if<
1140+
net::is_connect_condition<ConnectCondition,
1141+
decltype(std::declval<const EndpointSequence&>().begin())>::value
1142+
>::type
11351143
#endif
11361144
>
11371145
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
@@ -1204,7 +1212,13 @@ class basic_stream
12041212
BOOST_ASIO_COMPLETION_TOKEN_FOR(
12051213
void(error_code, Iterator))
12061214
IteratorConnectHandler =
1207-
net::default_completion_token_t<executor_type>>
1215+
net::default_completion_token_t<executor_type>
1216+
#if ! BOOST_BEAST_DOXYGEN
1217+
,class = typename std::enable_if<
1218+
!net::is_connect_condition<IteratorConnectHandler, Iterator>::value
1219+
>::type
1220+
#endif
1221+
>
12081222
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
12091223
IteratorConnectHandler,
12101224
void(error_code, Iterator))
@@ -1278,7 +1292,13 @@ class basic_stream
12781292
BOOST_ASIO_COMPLETION_TOKEN_FOR(
12791293
void(error_code, Iterator))
12801294
IteratorConnectHandler =
1281-
net::default_completion_token_t<executor_type>>
1295+
net::default_completion_token_t<executor_type>
1296+
#if ! BOOST_BEAST_DOXYGEN
1297+
,class = typename std::enable_if<
1298+
net::is_connect_condition<ConnectCondition, Iterator>::value
1299+
>::type
1300+
#endif
1301+
>
12821302
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(
12831303
IteratorConnectHandler,
12841304
void(error_code, Iterator))

include/boost/beast/core/impl/basic_stream.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ template<class Protocol, class Executor, class RatePolicy>
905905
template<
906906
class EndpointSequence,
907907
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, typename Protocol::endpoint)) RangeConnectHandler,
908+
class,
908909
class>
909910
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(RangeConnectHandler,void(error_code, typename Protocol::endpoint))
910911
basic_stream<Protocol, Executor, RatePolicy>::
@@ -927,6 +928,7 @@ template<
927928
class EndpointSequence,
928929
class ConnectCondition,
929930
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, typename Protocol::endpoint)) RangeConnectHandler,
931+
class,
930932
class>
931933
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(RangeConnectHandler,void (error_code, typename Protocol::endpoint))
932934
basic_stream<Protocol, Executor, RatePolicy>::
@@ -948,7 +950,8 @@ async_connect(
948950
template<class Protocol, class Executor, class RatePolicy>
949951
template<
950952
class Iterator,
951-
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, Iterator)) IteratorConnectHandler>
953+
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, Iterator)) IteratorConnectHandler,
954+
class>
952955
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(IteratorConnectHandler,void (error_code, Iterator))
953956
basic_stream<Protocol, Executor, RatePolicy>::
954957
async_connect(
@@ -969,7 +972,8 @@ template<class Protocol, class Executor, class RatePolicy>
969972
template<
970973
class Iterator,
971974
class ConnectCondition,
972-
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, Iterator)) IteratorConnectHandler>
975+
BOOST_ASIO_COMPLETION_TOKEN_FOR(void(error_code, Iterator)) IteratorConnectHandler,
976+
class>
973977
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(IteratorConnectHandler,void (error_code, Iterator))
974978
basic_stream<Protocol, Executor, RatePolicy>::
975979
async_connect(

include/boost/beast/websocket/impl/accept.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,11 @@ template<
603603
BOOST_BEAST_ASYNC_RESULT1(AcceptHandler)
604604
stream<NextLayer, deflateSupported>::
605605
async_accept(
606-
AcceptHandler&& handler)
606+
AcceptHandler&& handler,
607+
typename std::enable_if<
608+
! net::is_const_buffer_sequence<
609+
AcceptHandler>::value>::type*
610+
)
607611
{
608612
static_assert(is_async_stream<next_layer_type>::value,
609613
"AsyncStream type requirements not met");
@@ -627,6 +631,9 @@ stream<NextLayer, deflateSupported>::
627631
async_accept(
628632
ConstBufferSequence const& buffers,
629633
AcceptHandler&& handler,
634+
typename std::enable_if<
635+
net::is_const_buffer_sequence<
636+
ConstBufferSequence>::value>::type*,
630637
typename std::enable_if<
631638
! http::detail::is_header<
632639
ConstBufferSequence>::value>::type*

include/boost/beast/websocket/stream.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,13 @@ class stream
13811381
async_accept(
13821382
AcceptHandler&& handler =
13831383
net::default_completion_token_t<
1384-
executor_type>{});
1384+
executor_type>{}
1385+
#ifndef BOOST_BEAST_DOXYGEN
1386+
, typename std::enable_if<
1387+
! net::is_const_buffer_sequence<
1388+
AcceptHandler>::value>::type* = nullptr
1389+
#endif
1390+
);
13851391

13861392
/** Perform the WebSocket handshake asynchronously in the server role.
13871393
@@ -1454,6 +1460,9 @@ class stream
14541460
net::default_completion_token_t<
14551461
executor_type>{}
14561462
#ifndef BOOST_BEAST_DOXYGEN
1463+
, typename std::enable_if<
1464+
net::is_const_buffer_sequence<
1465+
ConstBufferSequence>::value>::type* = 0
14571466
, typename std::enable_if<
14581467
! http::detail::is_header<
14591468
ConstBufferSequence>::value>::type* = 0

0 commit comments

Comments
 (0)