2 // experimental/redirect_error.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_EXPERIMENTAL_REDIRECT_ERROR_HPP
12 #define BOOST_ASIO_EXPERIMENTAL_REDIRECT_ERROR_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/detail/type_traits.hpp>
20 #include <boost/system/error_code.hpp>
22 #include <boost/asio/detail/push_options.hpp>
26 namespace experimental {
28 /// Completion token type used to specify that an error produced by an
29 /// asynchronous operation is captured to an error_code variable.
31 * The redirect_error_t class is used to indicate that any error_code produced
32 * by an asynchronous operation is captured to a specified variable.
34 template <typename CompletionToken>
35 class redirect_error_t
40 redirect_error_t(BOOST_ASIO_MOVE_ARG(T) completion_token,
41 boost::system::error_code& ec)
42 : token_(BOOST_ASIO_MOVE_CAST(T)(completion_token)),
48 CompletionToken token_;
49 boost::system::error_code& ec_;
52 /// Create a completion token to capture error_code values to a variable.
53 template <typename CompletionToken>
54 inline redirect_error_t<typename decay<CompletionToken>::type> redirect_error(
55 CompletionToken&& completion_token, boost::system::error_code& ec)
57 return redirect_error_t<typename decay<CompletionToken>::type>(
58 BOOST_ASIO_MOVE_CAST(CompletionToken)(completion_token), ec);
61 } // namespace experimental
65 #include <boost/asio/detail/pop_options.hpp>
67 #include <boost/asio/experimental/impl/redirect_error.hpp>
69 #endif // BOOST_ASIO_EXPERIMENTAL_REDIRECT_ERROR_HPP