diff --git a/CHANGELOG.md b/CHANGELOG.md
index 69ce2e0c..8aecdc36 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,7 @@ API Changes:
* Rename to flat_buffer, basic_flat_buffer
* Rename to static_buffer, static_buffer_n
* Rename to buffered_read_stream
+* Harmonize concepts and identifiers with net-ts
--------------------------------------------------------------------------------
diff --git a/doc/quickref.xml b/doc/quickref.xml
index 0463d753..fc11461e 100644
--- a/doc/quickref.xml
+++ b/doc/quickref.xml
@@ -152,6 +152,7 @@
Classes
async_completion
+ async_result
basic_flat_buffer
basic_multi_buffer
buffers_adapter
@@ -183,6 +184,11 @@
prepare_buffers
system_category
+ Macros
+
+ BEAST_HANDLER_TYPE
+ BEAST_INITFN_RESULT_TYPE
+
Type Traits
@@ -190,11 +196,10 @@
is_AsyncReadStream
is_AsyncWriteStream
is_AsyncStream
- is_BufferSequence
is_CompletionHandler
- is_ConstBufferSequence
- is_DynamicBuffer
- is_MutableBufferSequence
+ is_const_buffer_sequence
+ is_dynamic_buffer
+ is_mutable_buffer_sequence
is_SyncReadStream
is_SyncStream
is_SyncWriteStream
diff --git a/doc/source.dox b/doc/source.dox
index f4707c41..ab9b8a49 100644
--- a/doc/source.dox
+++ b/doc/source.dox
@@ -282,7 +282,11 @@ EXPAND_ONLY_PREDEF = YES
SEARCH_INCLUDES = YES
INCLUDE_PATH = ../
INCLUDE_FILE_PATTERNS =
-PREDEFINED = BEAST_DOXYGEN
+
+PREDEFINED = \
+ BEAST_DOXYGEN \
+ BEAST_INITFN_RESULT_TYPE(t,a)=void_or_deduced
+
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
diff --git a/extras/beast/test/fail_stream.hpp b/extras/beast/test/fail_stream.hpp
index 8ec63dc5..f6f8127f 100644
--- a/extras/beast/test/fail_stream.hpp
+++ b/extras/beast/test/fail_stream.hpp
@@ -8,7 +8,7 @@
#ifndef BEAST_TEST_FAIL_STREAM_HPP
#define BEAST_TEST_FAIL_STREAM_HPP
-#include
+#include
#include
#include
#include
@@ -103,20 +103,19 @@ public:
}
template
- typename async_completion<
- ReadHandler, void(error_code)>::result_type
+ BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code, std::size_t))
async_read_some(MutableBufferSequence const& buffers,
ReadHandler&& handler)
{
error_code ec;
if(pfc_->fail(ec))
{
- async_completion<
- ReadHandler, void(error_code, std::size_t)
- > completion{handler};
+ async_completion init{handler};
next_layer_.get_io_service().post(
- bind_handler(completion.handler, ec, 0));
- return completion.result.get();
+ bind_handler(init.completion_handler, ec, 0));
+ return init.result.get();
}
return next_layer_.async_read_some(buffers,
std::forward(handler));
@@ -140,20 +139,19 @@ public:
}
template
- typename async_completion<
- WriteHandler, void(error_code)>::result_type
+ BEAST_INITFN_RESULT_TYPE(
+ WriteHandler, void(error_code, std::size_t))
async_write_some(ConstBufferSequence const& buffers,
WriteHandler&& handler)
{
error_code ec;
if(pfc_->fail(ec))
{
- async_completion<
- WriteHandler, void(error_code, std::size_t)
- > completion{handler};
+ async_completion init{handler};
next_layer_.get_io_service().post(
- bind_handler(completion.handler, ec, 0));
- return completion.result.get();
+ bind_handler(init.completion_handler, ec, 0));
+ return init.result.get();
}
return next_layer_.async_write_some(buffers,
std::forward(handler));
diff --git a/extras/beast/test/string_iostream.hpp b/extras/beast/test/string_iostream.hpp
index 81417084..29fc9e56 100644
--- a/extras/beast/test/string_iostream.hpp
+++ b/extras/beast/test/string_iostream.hpp
@@ -8,7 +8,7 @@
#ifndef BEAST_TEST_STRING_IOSTREAM_HPP
#define BEAST_TEST_STRING_IOSTREAM_HPP
-#include
+#include
#include
#include
#include
@@ -78,8 +78,8 @@ public:
}
template
- typename async_completion::result_type
+ BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code, std::size_t))
async_read_some(MutableBufferSequence const& buffers,
ReadHandler&& handler)
{
@@ -91,10 +91,10 @@ public:
else
ec = boost::asio::error::eof;
async_completion completion{handler};
+ void(error_code, std::size_t)> init{handler};
ios_.post(bind_handler(
- completion.handler, ec, n));
- return completion.result.get();
+ init.completion_handler, ec, n));
+ return init.result.get();
}
template
@@ -124,19 +124,18 @@ public:
}
template
- typename async_completion<
- WriteHandler, void(error_code)>::result_type
+ BEAST_INITFN_RESULT_TYPE(
+ WriteHandler, void(error_code, std::size_t))
async_write_some(ConstBufferSequence const& buffers,
WriteHandler&& handler)
{
error_code ec;
auto const bytes_transferred = write_some(buffers, ec);
- async_completion<
- WriteHandler, void(error_code, std::size_t)
- > completion{handler};
+ async_completion init{handler};
get_io_service().post(
- bind_handler(completion.handler, ec, bytes_transferred));
- return completion.result.get();
+ bind_handler(init.completion_handler, ec, bytes_transferred));
+ return init.result.get();
}
friend
diff --git a/extras/beast/test/string_istream.hpp b/extras/beast/test/string_istream.hpp
index c630505c..3f3dcc37 100644
--- a/extras/beast/test/string_istream.hpp
+++ b/extras/beast/test/string_istream.hpp
@@ -8,7 +8,7 @@
#ifndef BEAST_TEST_STRING_ISTREAM_HPP
#define BEAST_TEST_STRING_ISTREAM_HPP
-#include
+#include
#include
#include
#include
@@ -76,8 +76,8 @@ public:
}
template
- typename async_completion::result_type
+ BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code, std::size_t))
async_read_some(MutableBufferSequence const& buffers,
ReadHandler&& handler)
{
@@ -89,10 +89,10 @@ public:
else
ec = boost::asio::error::eof;
async_completion completion{handler};
+ void(error_code, std::size_t)> init{handler};
ios_.post(bind_handler(
- completion.handler, ec, n));
- return completion.result.get();
+ init.completion_handler, ec, n));
+ return init.result.get();
}
template
@@ -115,16 +115,16 @@ public:
}
template
- typename async_completion::result_type
+ BEAST_INITFN_RESULT_TYPE(
+ WriteHandler, void(error_code, std::size_t))
async_write_some(ConstBuffeSequence const& buffers,
WriteHandler&& handler)
{
async_completion completion{handler};
- ios_.post(bind_handler(completion.handler,
+ void(error_code, std::size_t)> init{handler};
+ ios_.post(bind_handler(init.completion_handler,
error_code{}, boost::asio::buffer_size(buffers)));
- return completion.result.get();
+ return init.result.get();
}
friend
diff --git a/extras/beast/test/string_ostream.hpp b/extras/beast/test/string_ostream.hpp
index bc5b7896..c59bfc9b 100644
--- a/extras/beast/test/string_ostream.hpp
+++ b/extras/beast/test/string_ostream.hpp
@@ -8,7 +8,7 @@
#ifndef BEAST_TEST_STRING_OSTREAM_HPP
#define BEAST_TEST_STRING_OSTREAM_HPP
-#include
+#include
#include
#include
#include
@@ -59,16 +59,16 @@ public:
}
template
- typename async_completion::result_type
+ BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code, std::size_t))
async_read_some(MutableBufferSequence const& buffers,
ReadHandler&& handler)
{
async_completion completion{handler};
- ios_.post(bind_handler(completion.handler,
+ void(error_code, std::size_t)> init{handler};
+ ios_.post(bind_handler(init.completion_handler,
boost::asio::error::eof, 0));
- return completion.result.get();
+ return init.result.get();
}
template
@@ -98,19 +98,18 @@ public:
}
template
- typename async_completion<
- WriteHandler, void(error_code)>::result_type
+ BEAST_INITFN_RESULT_TYPE(
+ WriteHandler, void(error_code, std::size_t))
async_write_some(ConstBufferSequence const& buffers,
WriteHandler&& handler)
{
error_code ec;
auto const bytes_transferred = write_some(buffers, ec);
- async_completion<
- WriteHandler, void(error_code, std::size_t)
- > completion{handler};
+ async_completion init{handler};
get_io_service().post(
- bind_handler(completion.handler, ec, bytes_transferred));
- return completion.result.get();
+ bind_handler(init.completion_handler, ec, bytes_transferred));
+ return init.result.get();
}
friend
diff --git a/include/beast/core.hpp b/include/beast/core.hpp
index 5f9e9cf7..9ceed1d4 100644
--- a/include/beast/core.hpp
+++ b/include/beast/core.hpp
@@ -10,7 +10,7 @@
#include
-#include
+#include
#include
#include
#include
diff --git a/include/beast/core/async_completion.hpp b/include/beast/core/async_completion.hpp
deleted file mode 100644
index 8c7f64d9..00000000
--- a/include/beast/core/async_completion.hpp
+++ /dev/null
@@ -1,88 +0,0 @@
-//
-// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
-//
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-//
-
-#ifndef BEAST_ASYNC_COMPLETION_HPP
-#define BEAST_ASYNC_COMPLETION_HPP
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace beast {
-
-/** Helper for customizing the return type of asynchronous initiation functions.
-
- This class template is used to transform caller-provided completion
- handlers in calls to asynchronous initiation functions. The transformation
- allows customization of the return type of the initiating function, and the
- function signature of the final handler.
-
- @tparam CompletionHandler A completion handler, or a user defined type
- with specializations for customizing the return type (for example,
- `boost::asio::use_future` or `boost::asio::yield_context`).
-
- @tparam Signature The callable signature of the final completion handler.
-
- Example:
- @code
- ...
- template
- typename async_completion::result_type
- async_initfn(..., CompletionHandler&& handler)
- {
- async_completion completion{handler};
- ...
- return completion.result.get();
- }
- @endcode
-
- @note See
- Library Foundations For Asynchronous Operations
-*/
-template
-struct async_completion
-{
- /** The type of the final handler called by the asynchronous initiation function.
-
- Objects of this type will be callable with the specified signature.
- */
- using handler_type =
- typename boost::asio::handler_type<
- CompletionHandler, Signature>::type;
-
- /// The type of the value returned by the asynchronous initiation function.
- using result_type = typename
- boost::asio::async_result::type;
-
- /** Construct the helper.
-
- @param token The completion handler. Copies will be made as
- required. If `CompletionHandler` is movable, it may also be moved.
- */
- async_completion(typename std::remove_reference::type& token)
- : handler(std::forward(token))
- , result(handler)
- {
- static_assert(is_CompletionHandler::value,
- "Handler requirements not met");
- }
-
- /// The final completion handler, callable with the specified signature.
- handler_type handler;
-
- /// The return value of the asynchronous initiation function.
- boost::asio::async_result result;
-};
-
-} // beast
-
-#endif
diff --git a/include/beast/core/async_result.hpp b/include/beast/core/async_result.hpp
new file mode 100644
index 00000000..9fadabb9
--- /dev/null
+++ b/include/beast/core/async_result.hpp
@@ -0,0 +1,188 @@
+//
+// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+
+#ifndef BEAST_ASYNC_COMPLETION_HPP
+#define BEAST_ASYNC_COMPLETION_HPP
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace beast {
+
+/** An interface for customising the behaviour of an initiating function.
+
+ The async_result class is used for determining:
+
+ @li the concrete completion handler type to be called at the end of the
+ asynchronous operation;
+
+ @li the initiating function return type; and
+
+ @li how the return value of the initiating function is obtained.
+
+ The trait allows the handler and return types to be determined at the point
+ where the specific completion handler signature is known.
+
+ This template takes advantage of specializations of both
+ `boost::asio_async_result` and `boost::asio::handler_type` for user-defined
+ completion token types. The primary template assumes that the
+ @b CompletionToken is the completion handler.
+
+ @see @ref BEAST_INITFN_RESULT_TYPE, @ref BEAST_HANDLER_TYPE
+*/
+template
+class async_result
+{
+ static_assert(! std::is_reference<
+ CompletionToken>::value, "");
+
+ boost::asio::async_result::type> impl_;
+
+ async_result(async_result const&) = delete;
+ async_result& operator=(async_result const&) = delete;
+
+public:
+ /// The concrete completion handler type for the specific signature.
+ using completion_handler_type =
+ typename boost::asio::handler_type<
+ CompletionToken, Signature>::type;
+
+ /// The return type of the initiating function.
+ using return_type =
+ typename boost::asio::async_result<
+ completion_handler_type>::type;
+
+ /** Construct an async result from a given handler.
+
+ When using a specalised async_result, the constructor has
+ an opportunity to initialise some state associated with the
+ completion handler, which is then returned from the initiating
+ function.
+ */
+ explicit
+ async_result(completion_handler_type& h)
+ : impl_(h)
+ {
+ }
+
+ /// Obtain the value to be returned from the initiating function.
+ return_type
+ get()
+ {
+ return impl_.get();
+ }
+};
+
+/** Helper for customizing the return type of asynchronous initiation functions.
+
+ This class template is used to transform caller-provided completion
+ handlers in calls to asynchronous initiation functions. The transformation
+ allows customization of the return type of the initiating function, and the
+ function signature of the final handler.
+
+ @tparam CompletionToken A completion handler, or a user defined type
+ with specializations for customizing the return type (for example,
+ `boost::asio::use_future` or `boost::asio::yield_context`).
+
+ @tparam Signature The callable signature of the final completion handler.
+
+ Example:
+ @code
+ ...
+ template
+ typename async_completion::result_type
+ async_initfn(..., CompletionToken&& handler)
+ {
+ async_completion completion{handler};
+ ...
+ return completion.result.get();
+ }
+ @endcode
+
+ @tparam CompletionToken Specifies the model used to obtain the result of
+ the asynchronous operation.
+
+ @tparam Signature The call signature for the completion handler type invoked
+ on completion of the asynchronous operation.
+
+ @note See
+ Working Draft, C++ Extensions for Networking
+*/
+template
+struct async_completion
+{
+ /** The type of the final handler called by the asynchronous initiation function.
+
+ Objects of this type will be callable with the specified signature.
+ */
+ using completion_handler_type = typename async_result<
+ typename std::decay::type,
+ Signature>::completion_handler_type;
+
+ /** Constructor
+
+ The constructor creates the concrete completion handler and
+ makes the link between the handler and the asynchronous
+ result.
+
+ @param token The completion token. If this is a regular completion
+ handler, copies may be made as needed. If the handler is movable,
+ it may also be moved.
+ */
+ explicit
+ async_completion(CompletionToken& token)
+ : completion_handler(static_cast::value,
+ completion_handler_type&, CompletionToken&&>::type>(token))
+ , result(completion_handler)
+ {
+ // CompletionToken is not invokable with the given signature
+ static_assert(is_CompletionHandler<
+ completion_handler_type, Signature>::value,
+ "CompletionToken requirements not met (Signature mismatch)");
+ }
+
+ /// The final completion handler, callable with the specified signature.
+ typename std::conditional::value,
+ completion_handler_type&,
+ completion_handler_type
+ >::type completion_handler;
+
+ /// The return value of the asynchronous initiation function.
+ async_result::type, Signature> result;
+};
+
+/// @file
+
+/** @def BEAST_INITFN_RESULT_TYPE(ct, sig)
+
+ A macro to customize the return value of asynchronous initiation functions.
+*/
+#define BEAST_INITFN_RESULT_TYPE(ct, sig) \
+ typename async_result< \
+ typename std::decay::type, sig>::return_type
+
+/** @def BEAST_HANDLER_TYPE(ct, sig)
+
+ A helper macro to convert a completion token to a completion handler type.
+*/
+#define BEAST_HANDLER_TYPE(ct, sig) \
+ typename async_result< \
+ typename std::decay::type, sig>::completion_handler_type
+
+} // beast
+
+#endif
diff --git a/include/beast/core/buffer_concepts.hpp b/include/beast/core/buffer_concepts.hpp
index aeef682f..948b118b 100644
--- a/include/beast/core/buffer_concepts.hpp
+++ b/include/beast/core/buffer_concepts.hpp
@@ -15,44 +15,37 @@
namespace beast {
-/// Determine if `T` meets the requirements of @b `BufferSequence`.
-template
+/// Determine if `T` meets the requirements of @b ConstBufferSequence.
+template
#if BEAST_DOXYGEN
-struct is_BufferSequence : std::integral_constant
+struct is_const_buffer_sequence : std::integral_constant
#else
-struct is_BufferSequence : detail::is_BufferSequence::type
+struct is_const_buffer_sequence :
+ detail::is_buffer_sequence::type
#endif
{
};
-/// Determine if `T` meets the requirements of @b `ConstBufferSequence`.
+/// Determine if `T` meets the requirements of @b DynamicBuffer.
template
#if BEAST_DOXYGEN
-struct is_ConstBufferSequence : std::integral_constant
+struct is_dynamic_buffer : std::integral_constant
#else
-struct is_ConstBufferSequence :
- is_BufferSequence
+struct is_dynamic_buffer :
+ detail::is_dynamic_buffer::type
#endif
{
};
-/// Determine if `T` meets the requirements of @b `DynamicBuffer`.
+/// Determine if `T` meets the requirements of @b MutableBufferSequence.
template
#if BEAST_DOXYGEN
-struct is_DynamicBuffer : std::integral_constant
+struct is_mutable_buffer_sequence : std::integral_constant
#else
-struct is_DynamicBuffer : detail::is_DynamicBuffer::type
-#endif
-{
-};
-
-/// Determine if `T` meets the requirements of @b `MutableBufferSequence`.
-template
-#if BEAST_DOXYGEN
-struct is_MutableBufferSequence : std::integral_constant
-#else
-struct is_MutableBufferSequence :
- is_BufferSequence
+struct is_mutable_buffer_sequence :
+ detail::is_buffer_sequence::type
#endif
{
};
diff --git a/include/beast/core/buffered_read_stream.hpp b/include/beast/core/buffered_read_stream.hpp
index 7fc9c69e..31a41ba3 100644
--- a/include/beast/core/buffered_read_stream.hpp
+++ b/include/beast/core/buffered_read_stream.hpp
@@ -9,7 +9,7 @@
#define BEAST_BUFFERED_READ_STREAM_HPP
#include
-#include
+#include
#include
#include
#include
@@ -90,7 +90,7 @@ namespace beast {
template
class buffered_read_stream
{
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
template
@@ -272,11 +272,7 @@ public:
manner equivalent to using `boost::asio::io_service::post`.
*/
template
-#if BEAST_DOXYGEN
- void_or_deduced
-#else
- typename async_completion::result_type
-#endif
+ BEAST_INITFN_RESULT_TYPE(ReadHandler, void(error_code))
async_read_some(MutableBufferSequence const& buffers,
ReadHandler&& handler);
@@ -347,11 +343,7 @@ public:
manner equivalent to using `boost::asio::io_service::post`.
*/
template
-#if BEAST_DOXYGEN
- void_or_deduced
-#else
- typename async_completion::result_type
-#endif
+ BEAST_INITFN_RESULT_TYPE(WriteHandler, void(error_code))
async_write_some(ConstBufferSequence const& buffers,
WriteHandler&& handler);
};
diff --git a/include/beast/core/buffers_adapter.hpp b/include/beast/core/buffers_adapter.hpp
index df9edf70..032a946b 100644
--- a/include/beast/core/buffers_adapter.hpp
+++ b/include/beast/core/buffers_adapter.hpp
@@ -32,7 +32,7 @@ namespace beast {
template
class buffers_adapter
{
- static_assert(is_MutableBufferSequence::value,
+ static_assert(is_mutable_buffer_sequence::value,
"MutableBufferSequence requirements not met");
using iter_type = typename MutableBufferSequence::const_iterator;
diff --git a/include/beast/core/consuming_buffers.hpp b/include/beast/core/consuming_buffers.hpp
index 2e09a418..cd32baa9 100644
--- a/include/beast/core/consuming_buffers.hpp
+++ b/include/beast/core/consuming_buffers.hpp
@@ -9,7 +9,6 @@
#define BEAST_CONSUMING_BUFFERS_HPP
#include
-#include
#include
#include
#include
diff --git a/include/beast/core/detail/buffer_concepts.hpp b/include/beast/core/detail/buffer_concepts.hpp
index 6391de4c..6a4e830f 100644
--- a/include/beast/core/detail/buffer_concepts.hpp
+++ b/include/beast/core/detail/buffer_concepts.hpp
@@ -33,7 +33,7 @@ using MutableBufferSequence =
BufferSequence;
template
-class is_BufferSequence
+class is_buffer_sequence
{
template >
@@ -88,19 +88,19 @@ public:
template
struct is_all_ConstBufferSequence
: std::integral_constant::type::value &&
+ is_buffer_sequence::type::value &&
is_all_ConstBufferSequence::value>
{
};
template
struct is_all_ConstBufferSequence
- : is_BufferSequence::type
+ : is_buffer_sequence::type
{
};
template
-class is_DynamicBuffer
+class is_dynamic_buffer
{
// size()
template().data()),
boost::asio::const_buffer>::type::value>>
static R check4(int);
@@ -138,7 +138,7 @@ class is_DynamicBuffer
// prepare()
template().prepare(1)),
boost::asio::mutable_buffer>::type::value>>
static R check5(int);
diff --git a/include/beast/core/detail/sync_ostream.hpp b/include/beast/core/detail/sync_ostream.hpp
index 5a4e0b47..aee673c6 100644
--- a/include/beast/core/detail/sync_ostream.hpp
+++ b/include/beast/core/detail/sync_ostream.hpp
@@ -51,7 +51,7 @@ sync_ostream::
write_some(ConstBufferSequence const& buffers)
{
static_assert(
- is_ConstBufferSequence::value,
+ is_const_buffer_sequence::value,
"ConstBufferSequence requirements not met");
error_code ec;
auto const n = write_some(buffers, ec);
@@ -67,7 +67,7 @@ write_some(ConstBufferSequence const& buffers,
error_code& ec)
{
static_assert(
- is_ConstBufferSequence::value,
+ is_const_buffer_sequence::value,
"ConstBufferSequence requirements not met");
std::size_t n = 0;
using boost::asio::buffer_cast;
diff --git a/include/beast/core/impl/buffered_read_stream.ipp b/include/beast/core/impl/buffered_read_stream.ipp
index 63a234cb..9b36d7b9 100644
--- a/include/beast/core/impl/buffered_read_stream.ipp
+++ b/include/beast/core/impl/buffered_read_stream.ipp
@@ -161,13 +161,12 @@ template
auto
buffered_read_stream::
async_write_some(ConstBufferSequence const& buffers,
- WriteHandler&& handler) ->
- typename async_completion<
- WriteHandler, void(error_code)>::result_type
+ WriteHandler&& handler) ->
+ BEAST_INITFN_RESULT_TYPE(WriteHandler, void(error_code))
{
static_assert(is_AsyncWriteStream::value,
"AsyncWriteStream requirements not met");
- static_assert(is_ConstBufferSequence<
+ static_assert(is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
static_assert(is_CompletionHandler::value,
"SyncReadStream requirements not met");
- static_assert(is_MutableBufferSequence<
+ static_assert(is_mutable_buffer_sequence<
MutableBufferSequence>::value,
"MutableBufferSequence requirements not met");
error_code ec;
@@ -205,7 +204,7 @@ read_some(MutableBufferSequence const& buffers,
{
static_assert(is_SyncReadStream::value,
"SyncReadStream requirements not met");
- static_assert(is_MutableBufferSequence<
+ static_assert(is_mutable_buffer_sequence<
MutableBufferSequence>::value,
"MutableBufferSequence requirements not met");
using boost::asio::buffer_size;
@@ -229,24 +228,21 @@ template
template
auto
buffered_read_stream::
-async_read_some(
- MutableBufferSequence const& buffers,
+async_read_some(MutableBufferSequence const& buffers,
ReadHandler&& handler) ->
- typename async_completion<
- ReadHandler, void(error_code)>::result_type
+ BEAST_INITFN_RESULT_TYPE(ReadHandler, void(error_code))
{
static_assert(is_AsyncReadStream::value,
"Stream requirements not met");
- static_assert(is_MutableBufferSequence<
+ static_assert(is_mutable_buffer_sequence<
MutableBufferSequence>::value,
"MutableBufferSequence requirements not met");
- beast::async_completion<
- ReadHandler, void(error_code, std::size_t)
- > completion{handler};
- read_some_op{
- completion.handler, *this, buffers};
- return completion.result.get();
+ async_completion init{handler};
+ read_some_op{
+ init.completion_handler, *this, buffers};
+ return init.result.get();
}
} // beast
diff --git a/include/beast/core/impl/consuming_buffers.ipp b/include/beast/core/impl/consuming_buffers.ipp
index cebf1195..44b9157e 100644
--- a/include/beast/core/impl/consuming_buffers.ipp
+++ b/include/beast/core/impl/consuming_buffers.ipp
@@ -9,7 +9,6 @@
#define BEAST_IMPL_CONSUMING_BUFFERS_IPP
#include
-#include
#include
#include
#include
@@ -163,7 +162,8 @@ consuming_buffers(BufferSequence const& bs)
, begin_(bs_.begin())
{
static_assert(
- is_BufferSequence::value,
+ is_const_buffer_sequence::value||
+ is_mutable_buffer_sequence::value,
"BufferSequence requirements not met");
}
diff --git a/include/beast/core/ostream.hpp b/include/beast/core/ostream.hpp
index 634caa50..8d992730 100644
--- a/include/beast/core/ostream.hpp
+++ b/include/beast/core/ostream.hpp
@@ -44,7 +44,7 @@ detail::buffers_helper
#endif
buffers(ConstBufferSequence const& b)
{
- static_assert(is_ConstBufferSequence<
+ static_assert(is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence not met");
return detail::buffers_helper<
@@ -86,7 +86,7 @@ detail::ostream_helper<
#endif
ostream(DynamicBuffer& buffer)
{
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
return detail::ostream_helper<
DynamicBuffer, char, std::char_traits,
diff --git a/include/beast/http/concepts.hpp b/include/beast/http/concepts.hpp
index 7c58502a..f0f6a754 100644
--- a/include/beast/http/concepts.hpp
+++ b/include/beast/http/concepts.hpp
@@ -159,7 +159,7 @@ struct is_Reader()),
std::declval().finish()
)> > : std::integral_constant::value &&
std::is_convertible().prepare(
diff --git a/include/beast/http/impl/async_read.ipp b/include/beast/http/impl/async_read.ipp
index af362f6b..de090523 100644
--- a/include/beast/http/impl/async_read.ipp
+++ b/include/beast/http/impl/async_read.ipp
@@ -572,34 +572,34 @@ template<
class DynamicBuffer,
bool isRequest, class Derived,
class ReadHandler>
-typename async_completion<
- ReadHandler, void(error_code, std::size_t)>::result_type
+BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code, std::size_t))
async_read_some(
AsyncReadStream& stream,
DynamicBuffer& dynabuf,
basic_parser& parser,
ReadHandler&& handler)
{
- beast::async_completion completion{handler};
+ async_completion init{handler};
switch(parser.state())
{
case parse_state::header:
case parse_state::chunk_header:
detail::read_some_buffer_op{
- completion.handler, stream, dynabuf, parser};
+ DynamicBuffer, isRequest, true, Derived, BEAST_HANDLER_TYPE(
+ ReadHandler, void(error_code, std::size_t))>{
+ init.completion_handler, stream, dynabuf, parser};
break;
default:
detail::read_some_body_op{
- completion.handler, stream, dynabuf, parser};
+ DynamicBuffer, isRequest, Derived, BEAST_HANDLER_TYPE(
+ ReadHandler, void(error_code, std::size_t))>{
+ init.completion_handler, stream, dynabuf, parser};
break;
}
- return completion.result.get();
+ return init.result.get();
}
template<
@@ -608,21 +608,21 @@ template<
bool isRequest, class Derived,
class ReadHandler>
inline
-typename async_completion<
- ReadHandler, void(error_code, std::size_t)>::result_type
+BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code, std::size_t))
async_read_some(
AsyncReadStream& stream,
DynamicBuffer& dynabuf,
basic_parser& parser,
ReadHandler&& handler)
{
- beast::async_completion completion{handler};
+ async_completion init{handler};
detail::read_some_buffer_op{
- completion.handler, stream, dynabuf, parser};
- return completion.result.get();
+ DynamicBuffer, isRequest, false, Derived, BEAST_HANDLER_TYPE(
+ ReadHandler, void(error_code, std::size_t))>{
+ init.completion_handler, stream, dynabuf, parser};
+ return init.result.get();
}
} // detail
@@ -634,8 +634,8 @@ template<
class DynamicBuffer,
bool isRequest, bool isDirect, class Derived,
class ReadHandler>
-typename async_completion<
- ReadHandler, void(error_code, std::size_t)>::result_type
+BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code, std::size_t))
async_read_some(
AsyncReadStream& stream,
DynamicBuffer& dynabuf,
@@ -644,7 +644,7 @@ async_read_some(
{
static_assert(is_AsyncReadStream::value,
"AsyncReadStream requirements not met");
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
BOOST_ASSERT(! parser.is_complete());
return detail::async_read_some(stream, dynabuf, parser,
@@ -656,8 +656,8 @@ template<
class DynamicBuffer,
bool isRequest, bool isDirect, class Derived,
class ReadHandler>
-typename async_completion<
- ReadHandler, void(error_code)>::result_type
+BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code))
async_read(
AsyncReadStream& stream,
DynamicBuffer& dynabuf,
@@ -666,15 +666,16 @@ async_read(
{
static_assert(is_AsyncReadStream::value,
"AsyncReadStream requirements not met");
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
BOOST_ASSERT(! parser.is_complete());
- beast::async_completion completion{handler};
+ async_completion init{handler};
detail::parse_op{
- completion.handler, stream, dynabuf, parser};
- return completion.result.get();
+ isRequest, isDirect, Derived, BEAST_HANDLER_TYPE(
+ ReadHandler, void(error_code))>{
+ init.completion_handler, stream, dynabuf, parser};
+ return init.result.get();
}
template<
@@ -682,8 +683,8 @@ template<
class DynamicBuffer,
bool isRequest, class Body, class Fields,
class ReadHandler>
-typename async_completion<
- ReadHandler, void(error_code)>::result_type
+BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code))
async_read(
AsyncReadStream& stream,
DynamicBuffer& dynabuf,
@@ -692,7 +693,7 @@ async_read(
{
static_assert(is_AsyncReadStream::value,
"AsyncReadStream requirements not met");
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
static_assert(is_Body::value,
"Body requirements not met");
@@ -701,13 +702,13 @@ async_read(
static_assert(is_Reader>::value,
"Reader requirements not met");
- beast::async_completion completion{handler};
+ async_completion init{handler};
detail::read_message_op{completion.handler,
- stream, dynabuf, msg};
- return completion.result.get();
+ isRequest, Body, Fields, BEAST_HANDLER_TYPE(
+ ReadHandler, void(error_code))>{
+ init.completion_handler, stream, dynabuf, msg};
+ return init.result.get();
}
} // http
diff --git a/include/beast/http/impl/basic_parser.ipp b/include/beast/http/impl/basic_parser.ipp
index f34a0e82..76e9a3a0 100644
--- a/include/beast/http/impl/basic_parser.ipp
+++ b/include/beast/http/impl/basic_parser.ipp
@@ -71,7 +71,7 @@ basic_parser::
write(ConstBufferSequence const& buffers,
error_code& ec)
{
- static_assert(is_ConstBufferSequence<
+ static_assert(is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
auto const buffer = maybe_flatten(buffers);
diff --git a/include/beast/http/impl/read.ipp b/include/beast/http/impl/read.ipp
index e14b5dd9..5fdc1f29 100644
--- a/include/beast/http/impl/read.ipp
+++ b/include/beast/http/impl/read.ipp
@@ -192,7 +192,7 @@ read_some(
{
static_assert(is_SyncReadStream::value,
"SyncReadStream requirements not met");
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
BOOST_ASSERT(! parser.is_complete());
error_code ec;
@@ -216,7 +216,7 @@ read_some(
{
static_assert(is_SyncReadStream::value,
"SyncReadStream requirements not met");
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
BOOST_ASSERT(! parser.is_complete());
return detail::read_some(stream, dynabuf, parser, ec);
@@ -234,7 +234,7 @@ read(
{
static_assert(is_SyncReadStream::value,
"SyncReadStream requirements not met");
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
BOOST_ASSERT(! parser.is_complete());
error_code ec;
@@ -256,7 +256,7 @@ read(
{
static_assert(is_SyncReadStream::value,
"SyncReadStream requirements not met");
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
BOOST_ASSERT(! parser.is_complete());
do
@@ -282,7 +282,7 @@ read(
{
static_assert(is_SyncReadStream::value,
"SyncReadStream requirements not met");
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
static_assert(is_Body::value,
"Body requirements not met");
@@ -310,7 +310,7 @@ read(
{
static_assert(is_SyncReadStream::value,
"SyncReadStream requirements not met");
- static_assert(is_DynamicBuffer::value,
+ static_assert(is_dynamic_buffer::value,
"DynamicBuffer requirements not met");
static_assert(is_Body::value,
"Body requirements not met");
diff --git a/include/beast/http/impl/write.ipp b/include/beast/http/impl/write.ipp
index d995cb0f..466845a0 100644
--- a/include/beast/http/impl/write.ipp
+++ b/include/beast/http/impl/write.ipp
@@ -213,16 +213,16 @@ write(SyncWriteStream& stream,
template
-typename async_completion<
- WriteHandler, void(error_code)>::result_type
+BEAST_INITFN_RESULT_TYPE(
+ WriteHandler, void(error_code))
async_write(AsyncWriteStream& stream,
header const& msg,
WriteHandler&& handler)
{
static_assert(is_AsyncWriteStream::value,
"AsyncWriteStream requirements not met");
- beast::async_completion completion{handler};
+ async_completion init{handler};
multi_buffer b;
{
auto os = ostream(b);
@@ -231,9 +231,9 @@ async_write(AsyncWriteStream& stream,
os << "\r\n";
}
detail::write_streambuf_op{
- completion.handler, stream, std::move(b)};
- return completion.result.get();
+ BEAST_HANDLER_TYPE(WriteHandler, void(error_code))>{
+ init.completion_handler, stream, std::move(b)};
+ return init.result.get();
}
//------------------------------------------------------------------------------
@@ -641,8 +641,8 @@ write(SyncWriteStream& stream,
template
-typename async_completion<
- WriteHandler, void(error_code)>::result_type
+BEAST_INITFN_RESULT_TYPE(
+ WriteHandler, void(error_code))
async_write(AsyncWriteStream& stream,
message const& msg,
WriteHandler&& handler)
@@ -656,11 +656,12 @@ async_write(AsyncWriteStream& stream,
static_assert(is_Writer>::value,
"Writer requirements not met");
- beast::async_completion completion{handler};
- detail::write_op{completion.handler, stream, msg};
- return completion.result.get();
+ async_completion init{handler};
+ detail::write_op{init.completion_handler, stream, msg};
+ return init.result.get();
}
//------------------------------------------------------------------------------
diff --git a/include/beast/http/read.hpp b/include/beast/http/read.hpp
index 6ddc6172..c7c4db32 100644
--- a/include/beast/http/read.hpp
+++ b/include/beast/http/read.hpp
@@ -9,7 +9,7 @@
#define BEAST_HTTP_READ_HPP
#include
-#include
+#include
#include
#include
#include
@@ -179,12 +179,8 @@ template<
class DynamicBuffer,
bool isRequest, bool isDirect, class Derived,
class ReadHandler>
-#if BEAST_DOXYGEN
-void_or_deduced
-#else
-typename async_completion<
- ReadHandler, void(error_code, std::size_t)>::result_type
-#endif
+BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code, std::size_t))
async_read_some(
AsyncReadStream& stream,
DynamicBuffer& dynabuf,
@@ -318,12 +314,8 @@ template<
class DynamicBuffer,
bool isRequest, bool isDirect, class Derived,
class ReadHandler>
-#if BEAST_DOXYGEN
-void_or_deduced
-#else
-typename async_completion<
- ReadHandler, void(error_code)>::result_type
-#endif
+BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code))
async_read(
AsyncReadStream& stream,
DynamicBuffer& dynabuf,
@@ -462,12 +454,8 @@ template<
class DynamicBuffer,
bool isRequest, class Body, class Fields,
class ReadHandler>
-#if BEAST_DOXYGEN
-void_or_deduced
-#else
-typename async_completion<
- ReadHandler, void(error_code)>::result_type
-#endif
+BEAST_INITFN_RESULT_TYPE(
+ ReadHandler, void(error_code))
async_read(
AsyncReadStream& stream,
DynamicBuffer& dynabuf,
diff --git a/include/beast/http/write.hpp b/include/beast/http/write.hpp
index 563a8690..3ec810db 100644
--- a/include/beast/http/write.hpp
+++ b/include/beast/http/write.hpp
@@ -11,7 +11,7 @@
#include
#include
#include
-#include
+#include
#include
#include
@@ -121,12 +121,8 @@ write(SyncWriteStream& stream,
template
-#if BEAST_DOXYGEN
-void_or_deduced
-#else
-typename async_completion<
- WriteHandler, void(error_code)>::result_type
-#endif
+BEAST_INITFN_RESULT_TYPE(
+ WriteHandler, void(error_code))
async_write(AsyncWriteStream& stream,
header const& msg,
WriteHandler&& handler);
@@ -240,12 +236,8 @@ write(SyncWriteStream& stream,
template
-#if BEAST_DOXYGEN
-void_or_deduced
-#else
-typename async_completion<
- WriteHandler, void(error_code)>::result_type
-#endif
+BEAST_INITFN_RESULT_TYPE(
+ WriteHandler, void(error_code))
async_write(AsyncWriteStream& stream,
message const& msg,
WriteHandler&& handler);
diff --git a/include/beast/websocket/detail/utf8_checker.hpp b/include/beast/websocket/detail/utf8_checker.hpp
index d8b14604..a7f20d8f 100644
--- a/include/beast/websocket/detail/utf8_checker.hpp
+++ b/include/beast/websocket/detail/utf8_checker.hpp
@@ -125,7 +125,7 @@ template
bool
utf8_checker_t<_>::write(ConstBufferSequence const& bs)
{
- static_assert(is_ConstBufferSequence::value,
+ static_assert(is_const_buffer_sequence::value,
"ConstBufferSequence requirements not met");
using boost::asio::buffer_cast;
using boost::asio::buffer_size;
diff --git a/include/beast/websocket/impl/accept.ipp b/include/beast/websocket/impl/accept.ipp
index 2543d0f7..6c2c6449 100644
--- a/include/beast/websocket/impl/accept.ipp
+++ b/include/beast/websocket/impl/accept.ipp
@@ -360,7 +360,7 @@ accept(ConstBufferSequence const& buffers)
{
static_assert(is_SyncStream::value,
"SyncStream requirements not met");
- static_assert(is_ConstBufferSequence<
+ static_assert(is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
error_code ec;
@@ -379,7 +379,7 @@ accept_ex(ConstBufferSequence const& buffers,
{
static_assert(is_SyncStream::value,
"SyncStream requirements not met");
- static_assert(is_ConstBufferSequence<
+ static_assert(is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
static_assert(detail::is_ResponseDecorator<
@@ -399,7 +399,7 @@ accept(ConstBufferSequence const& buffers, error_code& ec)
{
static_assert(is_SyncStream::value,
"SyncStream requirements not met");
- static_assert(is_ConstBufferSequence<
+ static_assert(is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
reset();
@@ -421,10 +421,10 @@ accept_ex(ConstBufferSequence const& buffers,
{
static_assert(is_SyncStream::value,
"SyncStream requirements not met");
- static_assert(is_ConstBufferSequence<
+ static_assert(is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
- static_assert(is_ConstBufferSequence<
+ static_assert(is_const_buffer_sequence<
ConstBufferSequence>::value,
"ConstBufferSequence requirements not met");
reset();
@@ -506,7 +506,7 @@ accept(http::header