// impl/redirect_error.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2022 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)
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
-#include <boost/asio/associated_executor.hpp>
-#include <boost/asio/associated_allocator.hpp>
+#include <boost/asio/associator.hpp>
#include <boost/asio/async_result.hpp>
#include <boost/asio/detail/handler_alloc_helpers.hpp>
#include <boost/asio/detail/handler_cont_helpers.hpp>
void operator()()
{
- handler_();
+ BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)();
}
#if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
>::type
operator()(BOOST_ASIO_MOVE_ARG(Arg) arg, BOOST_ASIO_MOVE_ARG(Args)... args)
{
- handler_(BOOST_ASIO_MOVE_CAST(Arg)(arg),
+ BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)(
+ BOOST_ASIO_MOVE_CAST(Arg)(arg),
BOOST_ASIO_MOVE_CAST(Args)(args)...);
}
BOOST_ASIO_MOVE_ARG(Args)... args)
{
ec_ = ec;
- handler_(BOOST_ASIO_MOVE_CAST(Args)(args)...);
+ BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)(
+ BOOST_ASIO_MOVE_CAST(Args)(args)...);
}
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
>::type
operator()(BOOST_ASIO_MOVE_ARG(Arg) arg)
{
- handler_(BOOST_ASIO_MOVE_CAST(Arg)(arg));
+ BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)(
+ BOOST_ASIO_MOVE_CAST(Arg)(arg));
}
void operator()(const boost::system::error_code& ec)
{
ec_ = ec;
- handler_();
+ BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)();
}
#define BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF(n) \
>::type \
operator()(BOOST_ASIO_MOVE_ARG(Arg) arg, BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
{ \
- handler_(BOOST_ASIO_MOVE_CAST(Arg)(arg), \
+ BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)( \
+ BOOST_ASIO_MOVE_CAST(Arg)(arg), \
BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
} \
\
BOOST_ASIO_VARIADIC_MOVE_PARAMS(n)) \
{ \
ec_ = ec; \
- handler_(BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
+ BOOST_ASIO_MOVE_OR_LVALUE(Handler)(handler_)( \
+ BOOST_ASIO_VARIADIC_MOVE_ARGS(n)); \
} \
/**/
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF)
typedef R type(Args...);
};
+# if defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
+
+template <typename R, typename... Args>
+struct redirect_error_signature<R(boost::system::error_code, Args...) &>
+{
+ typedef R type(Args...) &;
+};
+
+template <typename R, typename... Args>
+struct redirect_error_signature<R(const boost::system::error_code&, Args...) &>
+{
+ typedef R type(Args...) &;
+};
+
+template <typename R, typename... Args>
+struct redirect_error_signature<R(boost::system::error_code, Args...) &&>
+{
+ typedef R type(Args...) &&;
+};
+
+template <typename R, typename... Args>
+struct redirect_error_signature<R(const boost::system::error_code&, Args...) &&>
+{
+ typedef R type(Args...) &&;
+};
+
+# if defined(BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
+
+template <typename R, typename... Args>
+struct redirect_error_signature<
+ R(boost::system::error_code, Args...) noexcept>
+{
+ typedef R type(Args...) & noexcept;
+};
+
+template <typename R, typename... Args>
+struct redirect_error_signature<
+ R(const boost::system::error_code&, Args...) noexcept>
+{
+ typedef R type(Args...) & noexcept;
+};
+
+template <typename R, typename... Args>
+struct redirect_error_signature<
+ R(boost::system::error_code, Args...) & noexcept>
+{
+ typedef R type(Args...) & noexcept;
+};
+
+template <typename R, typename... Args>
+struct redirect_error_signature<
+ R(const boost::system::error_code&, Args...) & noexcept>
+{
+ typedef R type(Args...) & noexcept;
+};
+
+template <typename R, typename... Args>
+struct redirect_error_signature<
+ R(boost::system::error_code, Args...) && noexcept>
+{
+ typedef R type(Args...) && noexcept;
+};
+
+template <typename R, typename... Args>
+struct redirect_error_signature<
+ R(const boost::system::error_code&, Args...) && noexcept>
+{
+ typedef R type(Args...) && noexcept;
+};
+
+# endif // defined(BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
+# endif // defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
#else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
template <typename R>
BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF)
#undef BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF
+# if defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
+
+template <typename R>
+struct redirect_error_signature<R(boost::system::error_code) &>
+{
+ typedef R type() &;
+};
+
+template <typename R>
+struct redirect_error_signature<R(const boost::system::error_code&) &>
+{
+ typedef R type() &;
+};
+
+template <typename R>
+struct redirect_error_signature<R(boost::system::error_code) &&>
+{
+ typedef R type() &&;
+};
+
+template <typename R>
+struct redirect_error_signature<R(const boost::system::error_code&) &&>
+{
+ typedef R type() &&;
+};
+
+#define BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF(n) \
+ template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
+ struct redirect_error_signature< \
+ R(boost::system::error_code, BOOST_ASIO_VARIADIC_TARGS(n)) &> \
+ { \
+ typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)) &; \
+ }; \
+ \
+ template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
+ struct redirect_error_signature< \
+ R(const boost::system::error_code&, BOOST_ASIO_VARIADIC_TARGS(n)) &> \
+ { \
+ typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)) &; \
+ }; \
+ \
+ template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
+ struct redirect_error_signature< \
+ R(boost::system::error_code, BOOST_ASIO_VARIADIC_TARGS(n)) &&> \
+ { \
+ typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)) &&; \
+ }; \
+ \
+ template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
+ struct redirect_error_signature< \
+ R(const boost::system::error_code&, BOOST_ASIO_VARIADIC_TARGS(n)) &&> \
+ { \
+ typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)) &&; \
+ }; \
+ /**/
+ BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF)
+#undef BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF
+
+# if defined(BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
+
+template <typename R>
+struct redirect_error_signature<
+ R(boost::system::error_code) noexcept>
+{
+ typedef R type() noexcept;
+};
+
+template <typename R>
+struct redirect_error_signature<
+ R(const boost::system::error_code&) noexcept>
+{
+ typedef R type() noexcept;
+};
+
+template <typename R>
+struct redirect_error_signature<
+ R(boost::system::error_code) & noexcept>
+{
+ typedef R type() & noexcept;
+};
+
+template <typename R>
+struct redirect_error_signature<
+ R(const boost::system::error_code&) & noexcept>
+{
+ typedef R type() & noexcept;
+};
+
+template <typename R>
+struct redirect_error_signature<
+ R(boost::system::error_code) && noexcept>
+{
+ typedef R type() && noexcept;
+};
+
+template <typename R>
+struct redirect_error_signature<
+ R(const boost::system::error_code&) && noexcept>
+{
+ typedef R type() && noexcept;
+};
+
+#define BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF(n) \
+ template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
+ struct redirect_error_signature< \
+ R(boost::system::error_code, BOOST_ASIO_VARIADIC_TARGS(n)) noexcept> \
+ { \
+ typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)) noexcept; \
+ }; \
+ \
+ template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
+ struct redirect_error_signature< \
+ R(const boost::system::error_code&, \
+ BOOST_ASIO_VARIADIC_TARGS(n)) noexcept> \
+ { \
+ typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)) noexcept; \
+ }; \
+ \
+ template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
+ struct redirect_error_signature< \
+ R(boost::system::error_code, \
+ BOOST_ASIO_VARIADIC_TARGS(n)) & noexcept> \
+ { \
+ typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)) & noexcept; \
+ }; \
+ \
+ template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
+ struct redirect_error_signature< \
+ R(const boost::system::error_code&, \
+ BOOST_ASIO_VARIADIC_TARGS(n)) & noexcept> \
+ { \
+ typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)) & noexcept; \
+ }; \
+ \
+ template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
+ struct redirect_error_signature< \
+ R(boost::system::error_code, \
+ BOOST_ASIO_VARIADIC_TARGS(n)) && noexcept> \
+ { \
+ typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)) && noexcept; \
+ }; \
+ \
+ template <typename R, BOOST_ASIO_VARIADIC_TPARAMS(n)> \
+ struct redirect_error_signature< \
+ R(const boost::system::error_code&, \
+ BOOST_ASIO_VARIADIC_TARGS(n)) && noexcept> \
+ { \
+ typedef R type(BOOST_ASIO_VARIADIC_TARGS(n)) && noexcept; \
+ }; \
+ /**/
+ BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF)
+#undef BOOST_ASIO_PRIVATE_REDIRECT_ERROR_DEF
+
+# endif // defined(BOOST_ASIO_HAS_NOEXCEPT_FUNCTION_TYPE)
+# endif // defined(BOOST_ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
} // namespace detail
#endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)
};
-template <typename Handler, typename Executor>
-struct associated_executor<detail::redirect_error_handler<Handler>, Executor>
- : detail::associated_executor_forwarding_base<Handler, Executor>
+template <template <typename, typename> class Associator,
+ typename Handler, typename DefaultCandidate>
+struct associator<Associator,
+ detail::redirect_error_handler<Handler>, DefaultCandidate>
+ : Associator<Handler, DefaultCandidate>
{
- typedef typename associated_executor<Handler, Executor>::type type;
-
- static type get(
- const detail::redirect_error_handler<Handler>& h,
- const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
- {
- return associated_executor<Handler, Executor>::get(h.handler_, ex);
- }
-};
-
-template <typename Handler, typename Allocator>
-struct associated_allocator<detail::redirect_error_handler<Handler>, Allocator>
-{
- typedef typename associated_allocator<Handler, Allocator>::type type;
-
- static type get(
+ static typename Associator<Handler, DefaultCandidate>::type get(
const detail::redirect_error_handler<Handler>& h,
- const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
+ const DefaultCandidate& c = DefaultCandidate()) BOOST_ASIO_NOEXCEPT
{
- return associated_allocator<Handler, Allocator>::get(h.handler_, a);
+ return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
}
};