mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 21:34:46 +02:00
Fix move-only arguments in bind_handler
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Version 172:
|
||||
|
||||
* Tidy up websocket stream javadocs
|
||||
* Fix move-only arguments in bind_handler
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@@ -51,10 +51,10 @@ class bound_handler
|
||||
boost::is_placeholder<typename
|
||||
std::decay<Arg>::type>::value == 0,
|
||||
Arg&&>::type
|
||||
extract(Arg&& arg, Vals& vals)
|
||||
extract(Arg&& arg, Vals&& vals)
|
||||
{
|
||||
boost::ignore_unused(vals);
|
||||
return arg;
|
||||
return std::forward<Arg>(arg);
|
||||
}
|
||||
|
||||
template<class Arg, class Vals>
|
||||
@@ -101,7 +101,7 @@ class bound_handler
|
||||
index_sequence<S...>)
|
||||
{
|
||||
boost::ignore_unused(args);
|
||||
h(std::get<S>(args)...);
|
||||
h(std::get<S>(std::move(args))...);
|
||||
}
|
||||
|
||||
template<
|
||||
@@ -118,7 +118,7 @@ class bound_handler
|
||||
{
|
||||
boost::ignore_unused(args);
|
||||
boost::ignore_unused(vals);
|
||||
h(extract(std::get<S>(args),
|
||||
h(extract(std::get<S>(std::move(args)),
|
||||
std::forward<ValsTuple>(vals))...);
|
||||
}
|
||||
|
||||
|
@@ -81,6 +81,21 @@ public:
|
||||
s.wrap(copyable_handler{}));
|
||||
}
|
||||
|
||||
struct move_only
|
||||
{
|
||||
move_only() = default;
|
||||
move_only(move_only&&) = default;
|
||||
move_only(move_only const&) = delete;
|
||||
};
|
||||
|
||||
void
|
||||
testMoveOnly()
|
||||
{
|
||||
bind_handler([](move_only){}, move_only{})();
|
||||
bind_handler([](move_only){}, std::placeholders::_1)(move_only{});
|
||||
bind_handler([](move_only, move_only){}, move_only{}, std::placeholders::_1)(move_only{});
|
||||
}
|
||||
|
||||
void
|
||||
run() override
|
||||
{
|
||||
@@ -90,6 +105,7 @@ public:
|
||||
f();
|
||||
testPlaceholders();
|
||||
testAsioHandlerInvoke();
|
||||
testMoveOnly();
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user