bind_front_handler works with member functions

This commit is contained in:
Vinnie Falco
2019-02-14 16:16:04 -08:00
parent d410b429c0
commit 92add2afa6
2 changed files with 15 additions and 0 deletions

View File

@ -2,6 +2,7 @@ Version 215:
* basic_stream uses boost::shared_ptr
* Remove bind_back_handler
* bind_front_handler works with member functions
--------------------------------------------------------------------------------

View File

@ -217,6 +217,7 @@ class bind_front_wrapper
template<std::size_t... I, class... Ts>
void
invoke(
std::false_type,
mp11::index_sequence<I...>,
Ts&&... ts)
{
@ -224,6 +225,18 @@ class bind_front_wrapper
std::forward<Ts>(ts)...);
}
template<std::size_t... I, class... Ts>
void
invoke(
std::true_type,
mp11::index_sequence<I...>,
Ts&&... ts)
{
std::mem_fn(h_)(
detail::get<I>(std::move(args_))...,
std::forward<Ts>(ts)...);
}
public:
using result_type = void; // asio needs this
@ -243,6 +256,7 @@ public:
void operator()(Ts&&... ts)
{
invoke(
std::is_member_function_pointer<Handler>{},
mp11::index_sequence_for<Args...>{},
std::forward<Ts>(ts)...);
}