Decay bound arguments in handler wrapper parameters:

fix #1365

To reduce instantiations, the list of template parameters
to the bind and bind_front handler wrappers are decayed before
naming the class template.
This commit is contained in:
Vinnie Falco
2018-12-20 01:01:33 -08:00
parent f00237cb35
commit e7b8cc73a5
4 changed files with 72 additions and 21 deletions
+36
View File
@@ -12,6 +12,7 @@
#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/beast/_experimental/unit_test/suite.hpp>
#include <boost/beast/_experimental/test/stream.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/bind_executor.hpp>
#include <boost/asio/executor_work_guard.hpp>
@@ -41,6 +42,40 @@ public:
}
};
template <class AsyncReadStream, class ReadHandler>
void
signal_aborted (AsyncReadStream& stream, ReadHandler&& handler)
{
net::post(
stream.get_executor(),
bind_handler (std::forward <ReadHandler> (handler),
net::error::operation_aborted, 0));
}
template <class AsyncReadStream, class ReadHandler>
void
signal_eof (AsyncReadStream& stream, ReadHandler&& handler)
{
net::post(
stream.get_executor(),
bind_front_handler (std::forward<ReadHandler> (handler),
net::error::eof, 0));
}
void
testJavadocs()
{
BEAST_EXPECT((
&bind_handler_test::signal_aborted<
test::stream, handler<error_code, std::size_t>>));
BEAST_EXPECT((
&bind_handler_test::signal_eof<
test::stream, handler<error_code, std::size_t>>));
}
//--------------------------------------------------------------------------
struct copyable
{
template<class... Args>
@@ -469,6 +504,7 @@ public:
void
run() override
{
testJavadocs();
testBindHandler();
testBindFrontHandler();
}