Use separate SFINAE constraints for read_until and async_read_until.

This commit is contained in:
Christopher Kohlhoff 2021-03-04 09:44:59 +11:00
parent 80c71f02b5
commit 7e4772f73c
2 changed files with 108 additions and 36 deletions

View File

@ -79,7 +79,9 @@ inline std::size_t read_until(SyncReadStream& s,
ASIO_MOVE_ARG(DynamicBuffer_v1) buffers, char delim,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
asio::error_code ec;
@ -95,7 +97,9 @@ std::size_t read_until(SyncReadStream& s,
char delim, asio::error_code& ec,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
typename decay<DynamicBuffer_v1>::type b(
@ -149,7 +153,9 @@ inline std::size_t read_until(SyncReadStream& s,
ASIO_STRING_VIEW_PARAM delim,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
asio::error_code ec;
@ -165,7 +171,9 @@ std::size_t read_until(SyncReadStream& s,
ASIO_STRING_VIEW_PARAM delim, asio::error_code& ec,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
typename decay<DynamicBuffer_v1>::type b(
@ -231,7 +239,9 @@ inline std::size_t read_until(SyncReadStream& s,
const boost::regex& expr,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
asio::error_code ec;
@ -247,7 +257,9 @@ std::size_t read_until(SyncReadStream& s,
const boost::regex& expr, asio::error_code& ec,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
typename decay<DynamicBuffer_v1>::type b(
@ -315,8 +327,12 @@ inline std::size_t read_until(SyncReadStream& s,
MatchCondition match_condition,
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
asio::error_code ec;
@ -334,8 +350,12 @@ std::size_t read_until(SyncReadStream& s,
MatchCondition match_condition, asio::error_code& ec,
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
typename decay<DynamicBuffer_v1>::type b(
@ -699,7 +719,9 @@ inline std::size_t read_until(SyncReadStream& s,
DynamicBuffer_v2 buffers, MatchCondition match_condition,
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type,
typename constraint<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type)
{
asio::error_code ec;
@ -716,7 +738,9 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
MatchCondition match_condition, asio::error_code& ec,
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type,
typename constraint<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type)
{
DynamicBuffer_v2& b = buffers;
@ -1063,7 +1087,9 @@ async_read_until(AsyncReadStream& s,
char delim, ASIO_MOVE_ARG(ReadHandler) handler,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
return async_initiate<ReadHandler,
@ -1371,7 +1397,9 @@ async_read_until(AsyncReadStream& s,
ASIO_MOVE_ARG(ReadHandler) handler,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
return async_initiate<ReadHandler,
@ -1685,7 +1713,9 @@ async_read_until(AsyncReadStream& s,
ASIO_MOVE_ARG(ReadHandler) handler,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
return async_initiate<ReadHandler,
@ -1997,8 +2027,12 @@ async_read_until(AsyncReadStream& s,
MatchCondition match_condition, ASIO_MOVE_ARG(ReadHandler) handler,
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
>::type,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type)
{
return async_initiate<ReadHandler,
@ -3317,7 +3351,9 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
MatchCondition match_condition, ASIO_MOVE_ARG(ReadHandler) handler,
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type,
typename constraint<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type)
{
return async_initiate<ReadHandler,

View File

@ -135,7 +135,9 @@ std::size_t read_until(SyncReadStream& s,
ASIO_MOVE_ARG(DynamicBuffer_v1) buffers, char delim,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
/// Read data into a dynamic buffer sequence until it contains a specified
@ -178,7 +180,9 @@ std::size_t read_until(SyncReadStream& s,
char delim, asio::error_code& ec,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
/// Read data into a dynamic buffer sequence until it contains a specified
@ -238,7 +242,9 @@ std::size_t read_until(SyncReadStream& s,
ASIO_STRING_VIEW_PARAM delim,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
/// Read data into a dynamic buffer sequence until it contains a specified
@ -282,7 +288,9 @@ std::size_t read_until(SyncReadStream& s,
asio::error_code& ec,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
#if !defined(ASIO_NO_EXTENSIONS)
@ -349,7 +357,9 @@ std::size_t read_until(SyncReadStream& s,
const boost::regex& expr,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
/// Read data into a dynamic buffer sequence until some part of the data it
@ -394,7 +404,9 @@ std::size_t read_until(SyncReadStream& s,
const boost::regex& expr, asio::error_code& ec,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
#endif // defined(ASIO_HAS_BOOST_REGEX)
@ -509,8 +521,12 @@ std::size_t read_until(SyncReadStream& s,
MatchCondition match_condition,
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
/// Read data into a dynamic buffer sequence until a function object indicates a
@ -573,8 +589,12 @@ std::size_t read_until(SyncReadStream& s,
MatchCondition match_condition, asio::error_code& ec,
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
#if !defined(ASIO_NO_IOSTREAM)
@ -1436,7 +1456,9 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
MatchCondition match_condition,
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type = 0,
typename constraint<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type = 0);
/// Read data into a dynamic buffer sequence until a function object indicates a
@ -1498,7 +1520,9 @@ std::size_t read_until(SyncReadStream& s, DynamicBuffer_v2 buffers,
MatchCondition match_condition, asio::error_code& ec,
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type = 0,
typename constraint<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type = 0);
#endif // !defined(ASIO_NO_EXTENSIONS)
@ -1612,7 +1636,9 @@ async_read_until(AsyncReadStream& s,
typename AsyncReadStream::executor_type),
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
/// Start an asynchronous operation to read data into a dynamic buffer sequence
@ -1712,7 +1738,9 @@ async_read_until(AsyncReadStream& s,
typename AsyncReadStream::executor_type),
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
#if !defined(ASIO_NO_EXTENSIONS)
@ -1819,7 +1847,9 @@ async_read_until(AsyncReadStream& s,
typename AsyncReadStream::executor_type),
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
#endif // defined(ASIO_HAS_BOOST_REGEX)
@ -1969,8 +1999,12 @@ async_read_until(AsyncReadStream& s,
typename AsyncReadStream::executor_type),
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
&& !is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
is_dynamic_buffer_v1<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0,
typename constraint<
!is_dynamic_buffer_v2<typename decay<DynamicBuffer_v1>::type>::value
>::type = 0);
#if !defined(ASIO_NO_IOSTREAM)
@ -2847,7 +2881,9 @@ async_read_until(AsyncReadStream& s, DynamicBuffer_v2 buffers,
typename AsyncReadStream::executor_type),
typename constraint<
is_match_condition<MatchCondition>::value
&& is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type = 0,
typename constraint<
is_dynamic_buffer_v2<DynamicBuffer_v2>::value
>::type = 0);
#endif // !defined(ASIO_NO_EXTENSIONS)