diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b292ef2..98cac88e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,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 +* Support Concepts for completion token params -------------------------------------------------------------------------------- diff --git a/doc/source.dox b/doc/source.dox index eb82af24..ed06320b 100644 --- a/doc/source.dox +++ b/doc/source.dox @@ -49,9 +49,13 @@ PREDEFINED = \ BOOST_BEAST_SPLIT_COMPILATION=1 \ "BOOST_BEAST_ASYNC_RESULT1(t)=__deduced__" \ "BOOST_BEAST_ASYNC_RESULT2(t)=__deduced__" \ + "BOOST_BEAST_ASYNC_TPARAM1=class" \ + "BOOST_BEAST_ASYNC_TPARAM2=class" \ "BOOST_ASIO_INITFN_RESULT_TYPE(t,a)=__deduced__" \ + "BOOST_ASIO_COMPLETION_TOKEN_FOR(sig)=class" \ GENERATING_DOCUMENTATION \ BOOST_BEAST_DECL + EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES diff --git a/include/boost/beast/_experimental/http/icy_stream.hpp b/include/boost/beast/_experimental/http/icy_stream.hpp index bb6a8197..81730b58 100644 --- a/include/boost/beast/_experimental/http/icy_stream.hpp +++ b/include/boost/beast/_experimental/http/icy_stream.hpp @@ -224,7 +224,7 @@ public: */ template< class MutableBufferSequence, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT2(ReadHandler) @@ -306,7 +306,7 @@ public: */ template< class ConstBufferSequence, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT2(WriteHandler) diff --git a/include/boost/beast/_experimental/test/stream.hpp b/include/boost/beast/_experimental/test/stream.hpp index 6fe7bd8c..6b725ba1 100644 --- a/include/boost/beast/_experimental/test/stream.hpp +++ b/include/boost/beast/_experimental/test/stream.hpp @@ -477,7 +477,7 @@ public: */ template< class MutableBufferSequence, - class ReadHandler> + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler> BOOST_BEAST_ASYNC_RESULT2(ReadHandler) async_read_some( MutableBufferSequence const& buffers, @@ -555,7 +555,7 @@ public: */ template< class ConstBufferSequence, - class WriteHandler> + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler> BOOST_BEAST_ASYNC_RESULT2(WriteHandler) async_write_some( ConstBufferSequence const& buffers, diff --git a/include/boost/beast/core/basic_stream.hpp b/include/boost/beast/core/basic_stream.hpp index 4b376d5e..c92793e4 100644 --- a/include/boost/beast/core/basic_stream.hpp +++ b/include/boost/beast/core/basic_stream.hpp @@ -921,7 +921,7 @@ public: @see async_connect */ template< - class ConnectHandler = + BOOST_BEAST_ASYNC_TPARAM1 ConnectHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT1(ConnectHandler) @@ -974,15 +974,19 @@ public: */ template< class EndpointSequence, - class RangeConnectHandler = - net::default_completion_token_t + BOOST_ASIO_COMPLETION_TOKEN_FOR( + void(error_code, typename Protocol::endpoint)) + RangeConnectHandler = + net::default_completion_token_t #if ! BOOST_BEAST_DOXYGEN ,class = typename std::enable_if< net::is_endpoint_sequence< EndpointSequence>::value>::type #endif > - BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,void (error_code, typename Protocol::endpoint)) + BOOST_ASIO_INITFN_RESULT_TYPE( + RangeConnectHandler, + void(error_code, typename Protocol::endpoint)) async_connect( EndpointSequence const& endpoints, RangeConnectHandler&& handler = @@ -1063,15 +1067,19 @@ public: template< class EndpointSequence, class ConnectCondition, - class RangeConnectHandler = - net::default_completion_token_t + BOOST_ASIO_COMPLETION_TOKEN_FOR( + void(error_code, typename Protocol::endpoint)) + RangeConnectHandler = + net::default_completion_token_t #if ! BOOST_BEAST_DOXYGEN ,class = typename std::enable_if< net::is_endpoint_sequence< EndpointSequence>::value>::type #endif > - BOOST_ASIO_INITFN_RESULT_TYPE(RangeConnectHandler,void (error_code, typename Protocol::endpoint)) + BOOST_ASIO_INITFN_RESULT_TYPE( + RangeConnectHandler, + void(error_code, typename Protocol::endpoint)) async_connect( EndpointSequence const& endpoints, ConnectCondition connect_condition, @@ -1123,8 +1131,10 @@ public: */ template< class Iterator, - class IteratorConnectHandler = - net::default_completion_token_t> + BOOST_ASIO_COMPLETION_TOKEN_FOR( + void(error_code, Iterator)) + IteratorConnectHandler = + net::default_completion_token_t> BOOST_ASIO_INITFN_RESULT_TYPE( IteratorConnectHandler, void(error_code, Iterator)) @@ -1182,8 +1192,10 @@ public: template< class Iterator, class ConnectCondition, - class IteratorConnectHandler = - net::default_completion_token_t> + BOOST_ASIO_COMPLETION_TOKEN_FOR( + void(error_code, Iterator)) + IteratorConnectHandler = + net::default_completion_token_t> BOOST_ASIO_INITFN_RESULT_TYPE( IteratorConnectHandler, void(error_code, Iterator)) @@ -1306,7 +1318,7 @@ public: */ template< class MutableBufferSequence, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT2(ReadHandler) @@ -1429,7 +1441,7 @@ public: */ template< class ConstBufferSequence, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT2(WriteHandler) diff --git a/include/boost/beast/core/buffered_read_stream.hpp b/include/boost/beast/core/buffered_read_stream.hpp index 5e03e7b1..2d86a631 100644 --- a/include/boost/beast/core/buffered_read_stream.hpp +++ b/include/boost/beast/core/buffered_read_stream.hpp @@ -263,7 +263,7 @@ public: */ template< class MutableBufferSequence, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t> BOOST_BEAST_ASYNC_RESULT2(ReadHandler) async_read_some( @@ -342,7 +342,7 @@ public: */ template< class ConstBufferSequence, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t> BOOST_BEAST_ASYNC_RESULT2(WriteHandler) async_write_some( diff --git a/include/boost/beast/core/detail/config.hpp b/include/boost/beast/core/detail/config.hpp index 5dd637b1..7fad1fa8 100644 --- a/include/boost/beast/core/detail/config.hpp +++ b/include/boost/beast/core/detail/config.hpp @@ -90,7 +90,15 @@ namespace net = boost::asio; #ifndef BOOST_BEAST_ASYNC_RESULT2 #define BOOST_BEAST_ASYNC_RESULT2(type) \ - BOOST_ASIO_INITFN_AUTO_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 + +#ifndef BOOST_BEAST_ASYNC_TPARAM1 +#define BOOST_BEAST_ASYNC_TPARAM1 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::beast::error_code)) +#endif + +#ifndef BOOST_BEAST_ASYNC_TPARAM2 +#define BOOST_BEAST_ASYNC_TPARAM2 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::beast::error_code, ::std::size_t)) #endif #endif diff --git a/include/boost/beast/core/flat_stream.hpp b/include/boost/beast/core/flat_stream.hpp index aab0839d..913fdc3e 100644 --- a/include/boost/beast/core/flat_stream.hpp +++ b/include/boost/beast/core/flat_stream.hpp @@ -253,7 +253,7 @@ public: */ template< class MutableBufferSequence, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t> BOOST_BEAST_ASYNC_RESULT2(ReadHandler) async_read_some( @@ -334,7 +334,7 @@ public: */ template< class ConstBufferSequence, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t> BOOST_BEAST_ASYNC_RESULT2(WriteHandler) async_write_some( diff --git a/include/boost/beast/http/read.hpp b/include/boost/beast/http/read.hpp index 7a7dde04..492f2cfc 100644 --- a/include/boost/beast/http/read.hpp +++ b/include/boost/beast/http/read.hpp @@ -205,7 +205,7 @@ template< class AsyncReadStream, class DynamicBuffer, bool isRequest, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(ReadHandler) @@ -402,7 +402,7 @@ template< class AsyncReadStream, class DynamicBuffer, bool isRequest, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(ReadHandler) @@ -599,7 +599,7 @@ template< class AsyncReadStream, class DynamicBuffer, bool isRequest, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(ReadHandler) @@ -805,7 +805,7 @@ template< class AsyncReadStream, class DynamicBuffer, bool isRequest, class Body, class Allocator, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(ReadHandler) diff --git a/include/boost/beast/http/write.hpp b/include/boost/beast/http/write.hpp index 546479c5..be582fb0 100644 --- a/include/boost/beast/http/write.hpp +++ b/include/boost/beast/http/write.hpp @@ -166,7 +166,7 @@ write_some( template< class AsyncWriteStream, bool isRequest, class Body, class Fields, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(WriteHandler) @@ -296,7 +296,7 @@ write_header( template< class AsyncWriteStream, bool isRequest, class Body, class Fields, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(WriteHandler) @@ -417,7 +417,7 @@ write( template< class AsyncWriteStream, bool isRequest, class Body, class Fields, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(WriteHandler) @@ -642,7 +642,7 @@ write( template< class AsyncWriteStream, bool isRequest, class Body, class Fields, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(WriteHandler) @@ -704,7 +704,7 @@ async_write( template< class AsyncWriteStream, bool isRequest, class Body, class Fields, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(WriteHandler) diff --git a/include/boost/beast/websocket/stream.hpp b/include/boost/beast/websocket/stream.hpp index f23290d8..5b17061a 100644 --- a/include/boost/beast/websocket/stream.hpp +++ b/include/boost/beast/websocket/stream.hpp @@ -876,7 +876,7 @@ public: @li origin-form (RFC7230) */ template< - class HandshakeHandler = + BOOST_BEAST_ASYNC_TPARAM1 HandshakeHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT1(HandshakeHandler) @@ -962,7 +962,7 @@ public: @li origin-form (RFC7230) */ template< - class HandshakeHandler = + BOOST_BEAST_ASYNC_TPARAM1 HandshakeHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT1(HandshakeHandler) @@ -1286,7 +1286,7 @@ public: @li Websocket Opening Handshake Server Requirements (RFC6455) */ template< - class AcceptHandler = + BOOST_BEAST_ASYNC_TPARAM1 AcceptHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT1(AcceptHandler) @@ -1354,7 +1354,7 @@ public: */ template< class ConstBufferSequence, - class AcceptHandler = + BOOST_BEAST_ASYNC_TPARAM1 AcceptHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT1(AcceptHandler) @@ -1419,7 +1419,7 @@ public: */ template< class Body, class Allocator, - class AcceptHandler = + BOOST_BEAST_ASYNC_TPARAM1 AcceptHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT1(AcceptHandler) @@ -1554,7 +1554,7 @@ public: @li Websocket Closing Handshake (RFC6455) */ template< - class CloseHandler = + BOOST_BEAST_ASYNC_TPARAM1 CloseHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT1(CloseHandler) @@ -1656,7 +1656,7 @@ public: manner equivalent to using `net::post`. */ template< - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM1 WriteHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT1(WriteHandler) @@ -1764,7 +1764,7 @@ public: manner equivalent to using `net::post`. */ template< - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM1 WriteHandler = net::default_completion_token_t > BOOST_BEAST_ASYNC_RESULT1(WriteHandler) @@ -1926,7 +1926,7 @@ public: */ template< class DynamicBuffer, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(ReadHandler) @@ -2105,7 +2105,7 @@ public: */ template< class DynamicBuffer, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(ReadHandler) @@ -2280,7 +2280,7 @@ public: */ template< class MutableBufferSequence, - class ReadHandler = + BOOST_BEAST_ASYNC_TPARAM2 ReadHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(ReadHandler) @@ -2403,7 +2403,7 @@ public: */ template< class ConstBufferSequence, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(WriteHandler) @@ -2526,7 +2526,7 @@ public: */ template< class ConstBufferSequence, - class WriteHandler = + BOOST_BEAST_ASYNC_TPARAM2 WriteHandler = net::default_completion_token_t< executor_type>> BOOST_BEAST_ASYNC_RESULT2(WriteHandler)