1 | // |
2 | // prepend.hpp |
3 | // ~~~~~~~~~~~ |
4 | // |
5 | // Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com) |
6 | // |
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) |
9 | // |
10 | |
11 | #ifndef BOOST_ASIO_PREPEND_HPP |
12 | #define BOOST_ASIO_PREPEND_HPP |
13 | |
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) |
15 | # pragma once |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) |
17 | |
18 | #include <boost/asio/detail/config.hpp> |
19 | #include <tuple> |
20 | #include <boost/asio/detail/type_traits.hpp> |
21 | |
22 | #include <boost/asio/detail/push_options.hpp> |
23 | |
24 | namespace boost { |
25 | namespace asio { |
26 | |
27 | /// Completion token type used to specify that the completion handler |
28 | /// arguments should be passed additional values before the results of the |
29 | /// operation. |
30 | template <typename CompletionToken, typename... Values> |
31 | class prepend_t |
32 | { |
33 | public: |
34 | /// Constructor. |
35 | template <typename T, typename... V> |
36 | constexpr explicit prepend_t(T&& completion_token, V&&... values) |
37 | : token_(static_cast<T&&>(completion_token)), |
38 | values_(static_cast<V&&>(values)...) |
39 | { |
40 | } |
41 | |
42 | //private: |
43 | CompletionToken token_; |
44 | std::tuple<Values...> values_; |
45 | }; |
46 | |
47 | /// Completion token type used to specify that the completion handler |
48 | /// arguments should be passed additional values before the results of the |
49 | /// operation. |
50 | template <typename CompletionToken, typename... Values> |
51 | BOOST_ASIO_NODISCARD inline constexpr |
52 | prepend_t<decay_t<CompletionToken>, decay_t<Values>...> |
53 | prepend(CompletionToken&& completion_token, |
54 | Values&&... values) |
55 | { |
56 | return prepend_t<decay_t<CompletionToken>, decay_t<Values>...>( |
57 | static_cast<CompletionToken&&>(completion_token), |
58 | static_cast<Values&&>(values)...); |
59 | } |
60 | |
61 | } // namespace asio |
62 | } // namespace boost |
63 | |
64 | #include <boost/asio/detail/pop_options.hpp> |
65 | |
66 | #include <boost/asio/impl/prepend.hpp> |
67 | |
68 | #endif // BOOST_ASIO_PREPEND_HPP |
69 | |