Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:09

0001 //
0002 // consign.hpp
0003 // ~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_CONSIGN_HPP
0012 #define BOOST_ASIO_CONSIGN_HPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <tuple>
0020 #include <boost/asio/detail/type_traits.hpp>
0021 
0022 #include <boost/asio/detail/push_options.hpp>
0023 
0024 namespace boost {
0025 namespace asio {
0026 
0027 /// Completion token type used to specify that the completion handler should
0028 /// carry additional values along with it.
0029 /**
0030  * This completion token adapter is typically used to keep at least one copy of
0031  * an object, such as a smart pointer, alive until the completion handler is
0032  * called.
0033  */
0034 template <typename CompletionToken, typename... Values>
0035 class consign_t
0036 {
0037 public:
0038   /// Constructor.
0039   template <typename T, typename... V>
0040   constexpr explicit consign_t(T&& completion_token, V&&... values)
0041     : token_(static_cast<T&&>(completion_token)),
0042       values_(static_cast<V&&>(values)...)
0043   {
0044   }
0045 
0046 #if defined(GENERATING_DOCUMENTATION)
0047 private:
0048 #endif // defined(GENERATING_DOCUMENTATION)
0049   CompletionToken token_;
0050   std::tuple<Values...> values_;
0051 };
0052 
0053 /// Completion token adapter used to specify that the completion handler should
0054 /// carry additional values along with it.
0055 /**
0056  * This completion token adapter is typically used to keep at least one copy of
0057  * an object, such as a smart pointer, alive until the completion handler is
0058  * called.
0059  */
0060 template <typename CompletionToken, typename... Values>
0061 BOOST_ASIO_NODISCARD inline constexpr
0062 consign_t<decay_t<CompletionToken>, decay_t<Values>...>
0063 consign(CompletionToken&& completion_token, Values&&... values)
0064 {
0065   return consign_t<decay_t<CompletionToken>, decay_t<Values>...>(
0066       static_cast<CompletionToken&&>(completion_token),
0067       static_cast<Values&&>(values)...);
0068 }
0069 
0070 } // namespace asio
0071 } // namespace boost
0072 
0073 #include <boost/asio/detail/pop_options.hpp>
0074 
0075 #include <boost/asio/impl/consign.hpp>
0076 
0077 #endif // BOOST_ASIO_CONSIGN_HPP