bind_handler works with boost placeholders

This commit is contained in:
Vinnie Falco
2018-01-26 10:12:40 -08:00
parent 2f03cc7895
commit c9bbf7bdbc
2 changed files with 25 additions and 5 deletions

View File

@ -2,6 +2,7 @@ Version 154:
* Type check completion handlers
* bind_handler doc update
* bind_handler works with boost placeholders
--------------------------------------------------------------------------------

View File

@ -15,6 +15,7 @@
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/handler_continuation_hook.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/is_placeholder.hpp>
#include <functional>
#include <utility>
@ -45,8 +46,10 @@ class bound_handler
static
typename std::enable_if<
std::is_placeholder<typename
std::decay<Arg>::type>::value == 0 &&
boost::is_placeholder<typename
std::decay<Arg>::type>::value == 0,
Arg&&>::type
Arg&&>::type
extract(Arg&& arg, Vals& vals)
{
boost::ignore_unused(vals);
@ -58,10 +61,10 @@ class bound_handler
typename std::enable_if<
std::is_placeholder<typename
std::decay<Arg>::type>::value != 0,
typename std::tuple_element<
std::is_placeholder<
typename std::decay<Arg>::type>::value - 1,
Vals>::type&&>::type
typename std::tuple_element<
std::is_placeholder<
typename std::decay<Arg>::type>::value - 1,
Vals>>::type::type&&
extract(Arg&&, Vals&& vals)
{
return std::get<std::is_placeholder<
@ -69,6 +72,22 @@ class bound_handler
std::forward<Vals>(vals));
}
template<class Arg, class Vals>
static
typename std::enable_if<
boost::is_placeholder<typename
std::decay<Arg>::type>::value != 0,
typename std::tuple_element<
boost::is_placeholder<
typename std::decay<Arg>::type>::value - 1,
Vals>>::type::type&&
extract(Arg&&, Vals&& vals)
{
return std::get<boost::is_placeholder<
typename std::decay<Arg>::type>::value - 1>(
std::forward<Vals>(vals));
}
template<
class ArgsTuple,
std::size_t... S>