mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 21:34:46 +02:00
Use lean_tuple in bind_handler, bind_front_handler
This commit is contained in:
committed by
Vinnie Falco
parent
d40255b357
commit
98ff568371
@@ -4,6 +4,7 @@ Version 191:
|
|||||||
* Use bind_front_handler
|
* Use bind_front_handler
|
||||||
* Simplify some type traits
|
* Simplify some type traits
|
||||||
* Use lean_tuple in buffers_cat
|
* Use lean_tuple in buffers_cat
|
||||||
|
* Use lean_tuple in bind_handler, bind_front_handler
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
#define BOOST_BEAST_DETAIL_BIND_HANDLER_HPP
|
#define BOOST_BEAST_DETAIL_BIND_HANDLER_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/error.hpp>
|
#include <boost/beast/core/error.hpp>
|
||||||
#include <boost/beast/core/detail/integer_sequence.hpp>
|
#include <boost/beast/core/detail/lean_tuple.hpp>
|
||||||
#include <boost/asio/associated_allocator.hpp>
|
#include <boost/asio/associated_allocator.hpp>
|
||||||
#include <boost/asio/associated_executor.hpp>
|
#include <boost/asio/associated_executor.hpp>
|
||||||
#include <boost/asio/handler_continuation_hook.hpp>
|
#include <boost/asio/handler_continuation_hook.hpp>
|
||||||
@@ -22,6 +22,8 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
@@ -29,7 +31,7 @@ namespace detail {
|
|||||||
template<class Handler, class... Args>
|
template<class Handler, class... Args>
|
||||||
class bind_wrapper
|
class bind_wrapper
|
||||||
{
|
{
|
||||||
using args_type = std::tuple<
|
using args_type = detail::lean_tuple<
|
||||||
typename std::decay<Args>::type...>;
|
typename std::decay<Args>::type...>;
|
||||||
|
|
||||||
Handler h_;
|
Handler h_;
|
||||||
@@ -59,13 +61,12 @@ class bind_wrapper
|
|||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
std::is_placeholder<typename
|
std::is_placeholder<typename
|
||||||
std::decay<Arg>::type>::value != 0,
|
std::decay<Arg>::type>::value != 0,
|
||||||
typename std::tuple_element<
|
tuple_element<std::is_placeholder<
|
||||||
std::is_placeholder<
|
typename std::decay<Arg>::type>::value - 1,
|
||||||
typename std::decay<Arg>::type>::value - 1,
|
Vals>>::type&&
|
||||||
Vals>>::type::type&&
|
|
||||||
extract(Arg&&, Vals&& vals)
|
extract(Arg&&, Vals&& vals)
|
||||||
{
|
{
|
||||||
return std::get<std::is_placeholder<
|
return detail::get<std::is_placeholder<
|
||||||
typename std::decay<Arg>::type>::value - 1>(
|
typename std::decay<Arg>::type>::value - 1>(
|
||||||
std::forward<Vals>(vals));
|
std::forward<Vals>(vals));
|
||||||
}
|
}
|
||||||
@@ -75,13 +76,12 @@ class bind_wrapper
|
|||||||
typename std::enable_if<
|
typename std::enable_if<
|
||||||
boost::is_placeholder<typename
|
boost::is_placeholder<typename
|
||||||
std::decay<Arg>::type>::value != 0,
|
std::decay<Arg>::type>::value != 0,
|
||||||
typename std::tuple_element<
|
tuple_element<boost::is_placeholder<
|
||||||
boost::is_placeholder<
|
typename std::decay<Arg>::type>::value - 1,
|
||||||
typename std::decay<Arg>::type>::value - 1,
|
Vals>>::type&&
|
||||||
Vals>>::type::type&&
|
|
||||||
extract(Arg&&, Vals&& vals)
|
extract(Arg&&, Vals&& vals)
|
||||||
{
|
{
|
||||||
return std::get<boost::is_placeholder<
|
return detail::get<boost::is_placeholder<
|
||||||
typename std::decay<Arg>::type>::value - 1>(
|
typename std::decay<Arg>::type>::value - 1>(
|
||||||
std::forward<Vals>(vals));
|
std::forward<Vals>(vals));
|
||||||
}
|
}
|
||||||
@@ -92,13 +92,13 @@ class bind_wrapper
|
|||||||
static
|
static
|
||||||
void
|
void
|
||||||
invoke(
|
invoke(
|
||||||
Handler& w,
|
Handler& h,
|
||||||
ArgsTuple& args,
|
ArgsTuple& args,
|
||||||
std::tuple<>&&,
|
lean_tuple<>&&,
|
||||||
index_sequence<S...>)
|
mp11::index_sequence<S...>)
|
||||||
{
|
{
|
||||||
boost::ignore_unused(args);
|
boost::ignore_unused(args);
|
||||||
w(std::get<S>(std::move(args))...);
|
h(detail::get<S>(std::move(args))...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
template<
|
||||||
@@ -108,14 +108,14 @@ class bind_wrapper
|
|||||||
static
|
static
|
||||||
void
|
void
|
||||||
invoke(
|
invoke(
|
||||||
Handler& w,
|
Handler& h,
|
||||||
ArgsTuple& args,
|
ArgsTuple& args,
|
||||||
ValsTuple&& vals,
|
ValsTuple&& vals,
|
||||||
index_sequence<S...>)
|
mp11::index_sequence<S...>)
|
||||||
{
|
{
|
||||||
boost::ignore_unused(args);
|
boost::ignore_unused(args);
|
||||||
boost::ignore_unused(vals);
|
boost::ignore_unused(vals);
|
||||||
w(extract(std::get<S>(std::move(args)),
|
h(extract(detail::get<S>(std::move(args)),
|
||||||
std::forward<ValsTuple>(vals))...);
|
std::forward<ValsTuple>(vals))...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,9 +164,9 @@ public:
|
|||||||
operator()(Values&&... values)
|
operator()(Values&&... values)
|
||||||
{
|
{
|
||||||
invoke(h_, args_,
|
invoke(h_, args_,
|
||||||
std::forward_as_tuple(
|
lean_tuple<Values&&...>(
|
||||||
std::forward<Values>(values)...),
|
std::forward<Values>(values)...),
|
||||||
index_sequence_for<Args...>());
|
mp11::index_sequence_for<Args...>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class... Values>
|
template<class... Values>
|
||||||
@@ -174,9 +174,9 @@ public:
|
|||||||
operator()(Values&&... values) const
|
operator()(Values&&... values) const
|
||||||
{
|
{
|
||||||
invoke(h_, args_,
|
invoke(h_, args_,
|
||||||
std::forward_as_tuple(
|
lean_tuple<Values&&...>(
|
||||||
std::forward<Values>(values)...),
|
std::forward<Values>(values)...),
|
||||||
index_sequence_for<Args...>());
|
mp11::index_sequence_for<Args...>());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ template<class Handler,
|
|||||||
class Arg1, class Arg2, class Arg3, class... Args>
|
class Arg1, class Arg2, class Arg3, class... Args>
|
||||||
class bind_front_wrapper<Handler, Arg1, Arg2, Arg3, Args...>
|
class bind_front_wrapper<Handler, Arg1, Arg2, Arg3, Args...>
|
||||||
{
|
{
|
||||||
using args_type = std::tuple<
|
using args_type = lean_tuple<
|
||||||
typename std::decay<Arg1>::type,
|
typename std::decay<Arg1>::type,
|
||||||
typename std::decay<Arg2>::type,
|
typename std::decay<Arg2>::type,
|
||||||
typename std::decay<Arg3>::type,
|
typename std::decay<Arg3>::type,
|
||||||
@@ -384,10 +384,10 @@ class bind_front_wrapper<Handler, Arg1, Arg2, Arg3, Args...>
|
|||||||
template<std::size_t... I, class... Ts>
|
template<std::size_t... I, class... Ts>
|
||||||
void
|
void
|
||||||
invoke(
|
invoke(
|
||||||
boost::mp11::index_sequence<I...>,
|
mp11::index_sequence<I...>,
|
||||||
Ts&&... ts)
|
Ts&&... ts)
|
||||||
{
|
{
|
||||||
h_( std::get<I>(std::move(args_))...,
|
h_( detail::get<I>(std::move(args_))...,
|
||||||
std::forward<Ts>(ts)...);
|
std::forward<Ts>(ts)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,7 +439,7 @@ public:
|
|||||||
void operator()(Ts&&... ts)
|
void operator()(Ts&&... ts)
|
||||||
{
|
{
|
||||||
invoke(
|
invoke(
|
||||||
boost::mp11::index_sequence_for<
|
mp11::index_sequence_for<
|
||||||
Arg1, Arg2, Arg3, Args...>{},
|
Arg1, Arg2, Arg3, Args...>{},
|
||||||
std::forward<Ts>(ts)...);
|
std::forward<Ts>(ts)...);
|
||||||
}
|
}
|
||||||
|
@@ -77,7 +77,7 @@ get(lean_tuple_element<I, T>&& te)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t I, class T>
|
template <std::size_t I, class T>
|
||||||
using tuple_element_t = typename boost::copy_cv<
|
using tuple_element = typename boost::copy_cv<
|
||||||
mp11::mp_at_c<typename remove_cv<T>::type, I>, T>::type;
|
mp11::mp_at_c<typename remove_cv<T>::type, I>, T>::type;
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
|
Reference in New Issue
Block a user