append.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // append.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. #ifndef BOOST_ASIO_APPEND_HPP
  11. #define BOOST_ASIO_APPEND_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <tuple>
  17. #include <boost/asio/detail/type_traits.hpp>
  18. #include <boost/asio/detail/push_options.hpp>
  19. namespace boost {
  20. namespace asio {
  21. /// Completion token type used to specify that the completion handler
  22. /// arguments should be passed additional values after the results of the
  23. /// operation.
  24. template <typename CompletionToken, typename... Values>
  25. class append_t
  26. {
  27. public:
  28. /// Constructor.
  29. template <typename T, typename... V>
  30. constexpr explicit append_t(T&& completion_token, V&&... values)
  31. : token_(static_cast<T&&>(completion_token)),
  32. values_(static_cast<V&&>(values)...)
  33. {
  34. }
  35. //private:
  36. CompletionToken token_;
  37. std::tuple<Values...> values_;
  38. };
  39. /// Completion token type used to specify that the completion handler
  40. /// arguments should be passed additional values after the results of the
  41. /// operation.
  42. template <typename CompletionToken, typename... Values>
  43. BOOST_ASIO_NODISCARD inline constexpr
  44. append_t<decay_t<CompletionToken>, decay_t<Values>...>
  45. append(CompletionToken&& completion_token, Values&&... values)
  46. {
  47. return append_t<decay_t<CompletionToken>, decay_t<Values>...>(
  48. static_cast<CompletionToken&&>(completion_token),
  49. static_cast<Values&&>(values)...);
  50. }
  51. } // namespace asio
  52. } // namespace boost
  53. #include <boost/asio/detail/pop_options.hpp>
  54. #include <boost/asio/impl/append.hpp>
  55. #endif // BOOST_ASIO_APPEND_HPP