Fix move-only arguments in bind_handler

This commit is contained in:
Vinnie Falco
2018-05-27 19:05:43 -07:00
parent 3d7f1e7303
commit f948c9cbe5
3 changed files with 21 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
Version 172:
* Tidy up websocket stream javadocs
* Fix move-only arguments in bind_handler
--------------------------------------------------------------------------------

View File

@@ -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))...);
}

View File

@@ -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();
}
};