summaryrefslogtreecommitdiff
path: root/boost/asio/impl/spawn.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/asio/impl/spawn.hpp')
-rw-r--r--boost/asio/impl/spawn.hpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/boost/asio/impl/spawn.hpp b/boost/asio/impl/spawn.hpp
index ec1ff45d19..c2da5ce09a 100644
--- a/boost/asio/impl/spawn.hpp
+++ b/boost/asio/impl/spawn.hpp
@@ -2,7 +2,7 @@
// impl/spawn.hpp
// ~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -245,7 +245,7 @@ public:
explicit async_result(
typename detail::coro_async_result<Handler,
typename decay<Arg1>::type>::completion_handler_type& h)
- : detail::coro_async_result<Handler, Arg1>(h)
+ : detail::coro_async_result<Handler, typename decay<Arg1>::type>(h)
{
}
};
@@ -273,7 +273,7 @@ public:
explicit async_result(
typename detail::coro_async_result<Handler,
typename decay<Arg2>::type>::completion_handler_type& h)
- : detail::coro_async_result<Handler, Arg2>(h)
+ : detail::coro_async_result<Handler, typename decay<Arg2>::type>(h)
{
}
};
@@ -315,7 +315,7 @@ public:
explicit async_result(
typename detail::coro_async_result<Handler,
- void>::completion_handler_type& h)
+ T>::completion_handler_type& h)
: detail::coro_async_result<Handler, T>(h)
{
}
@@ -352,11 +352,12 @@ namespace detail {
template <typename Handler, typename Function>
struct spawn_data : private noncopyable
{
- spawn_data(BOOST_ASIO_MOVE_ARG(Handler) handler,
- bool call_handler, BOOST_ASIO_MOVE_ARG(Function) function)
- : handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)),
+ template <typename Hand, typename Func>
+ spawn_data(BOOST_ASIO_MOVE_ARG(Hand) handler,
+ bool call_handler, BOOST_ASIO_MOVE_ARG(Func) function)
+ : handler_(BOOST_ASIO_MOVE_CAST(Hand)(handler)),
call_handler_(call_handler),
- function_(BOOST_ASIO_MOVE_CAST(Function)(function))
+ function_(BOOST_ASIO_MOVE_CAST(Func)(function))
{
}
@@ -442,6 +443,7 @@ void spawn(BOOST_ASIO_MOVE_ARG(Handler) handler,
!is_convertible<Handler&, execution_context&>::value>::type*)
{
typedef typename decay<Handler>::type handler_type;
+ typedef typename decay<Function>::type function_type;
typename associated_executor<handler_type>::type ex(
(get_associated_executor)(handler));
@@ -449,9 +451,9 @@ void spawn(BOOST_ASIO_MOVE_ARG(Handler) handler,
typename associated_allocator<handler_type>::type a(
(get_associated_allocator)(handler));
- detail::spawn_helper<handler_type, Function> helper;
+ detail::spawn_helper<handler_type, function_type> helper;
helper.data_.reset(
- new detail::spawn_data<handler_type, Function>(
+ new detail::spawn_data<handler_type, function_type>(
BOOST_ASIO_MOVE_CAST(Handler)(handler), true,
BOOST_ASIO_MOVE_CAST(Function)(function)));
helper.attributes_ = attributes;
@@ -464,6 +466,8 @@ void spawn(basic_yield_context<Handler> ctx,
BOOST_ASIO_MOVE_ARG(Function) function,
const boost::coroutines::attributes& attributes)
{
+ typedef typename decay<Function>::type function_type;
+
Handler handler(ctx.handler_); // Explicit copy that might be moved from.
typename associated_executor<Handler>::type ex(
@@ -472,9 +476,9 @@ void spawn(basic_yield_context<Handler> ctx,
typename associated_allocator<Handler>::type a(
(get_associated_allocator)(handler));
- detail::spawn_helper<Handler, Function> helper;
+ detail::spawn_helper<Handler, function_type> helper;
helper.data_.reset(
- new detail::spawn_data<Handler, Function>(
+ new detail::spawn_data<Handler, function_type>(
BOOST_ASIO_MOVE_CAST(Handler)(handler), false,
BOOST_ASIO_MOVE_CAST(Function)(function)));
helper.attributes_ = attributes;