Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/asio/detail/completion_payload_handler.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //
0002 // detail/completion_payload_handler.hpp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2024 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_DETAIL_COMPLETION_PAYLOAD_HANDLER_HPP
0012 #define BOOST_ASIO_DETAIL_COMPLETION_PAYLOAD_HANDLER_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 <boost/asio/associator.hpp>
0020 
0021 #include <boost/asio/detail/push_options.hpp>
0022 
0023 namespace boost {
0024 namespace asio {
0025 namespace detail {
0026 
0027 template <typename Payload, typename Handler>
0028 class completion_payload_handler
0029 {
0030 public:
0031   completion_payload_handler(Payload&& p, Handler& h)
0032     : payload_(static_cast<Payload&&>(p)),
0033       handler_(static_cast<Handler&&>(h))
0034   {
0035   }
0036 
0037   void operator()()
0038   {
0039     payload_.receive(handler_);
0040   }
0041 
0042   Handler& handler()
0043   {
0044     return handler_;
0045   }
0046 
0047 //private:
0048   Payload payload_;
0049   Handler handler_;
0050 };
0051 
0052 } // namespace detail
0053 
0054 template <template <typename, typename> class Associator,
0055     typename Payload, typename Handler, typename DefaultCandidate>
0056 struct associator<Associator,
0057     detail::completion_payload_handler<Payload, Handler>,
0058     DefaultCandidate>
0059   : Associator<Handler, DefaultCandidate>
0060 {
0061   static typename Associator<Handler, DefaultCandidate>::type get(
0062       const detail::completion_payload_handler<Payload, Handler>& h) noexcept
0063   {
0064     return Associator<Handler, DefaultCandidate>::get(h.handler_);
0065   }
0066 
0067   static auto get(
0068       const detail::completion_payload_handler<Payload, Handler>& h,
0069       const DefaultCandidate& c) noexcept
0070     -> decltype(Associator<Handler, DefaultCandidate>::get(h.handler_, c))
0071   {
0072     return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
0073   }
0074 };
0075 
0076 } // namespace asio
0077 } // namespace boost
0078 
0079 #include <boost/asio/detail/pop_options.hpp>
0080 
0081 #endif // BOOST_ASIO_DETAIL_COMPLETION_PAYLOAD_HANDLER_HPP