Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:55

0001 //
0002 // impl/deferred.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_IMPL_DEFERRED_HPP
0012 #define BOOST_ASIO_IMPL_DEFERRED_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/push_options.hpp>
0019 
0020 namespace boost {
0021 namespace asio {
0022 
0023 #if !defined(GENERATING_DOCUMENTATION)
0024 
0025 template <typename Signature>
0026 class async_result<deferred_t, Signature>
0027 {
0028 public:
0029   template <typename Initiation, typename... InitArgs>
0030   static deferred_async_operation<Signature, Initiation, InitArgs...>
0031   initiate(Initiation&& initiation, deferred_t, InitArgs&&... args)
0032   {
0033     return deferred_async_operation<Signature, Initiation, InitArgs...>(
0034         deferred_init_tag{},
0035         static_cast<Initiation&&>(initiation),
0036         static_cast<InitArgs&&>(args)...);
0037   }
0038 };
0039 
0040 template <typename... Signatures>
0041 class async_result<deferred_t, Signatures...>
0042 {
0043 public:
0044   template <typename Initiation, typename... InitArgs>
0045   static deferred_async_operation<
0046       deferred_signatures<Signatures...>, Initiation, InitArgs...>
0047   initiate(Initiation&& initiation, deferred_t, InitArgs&&... args)
0048   {
0049     return deferred_async_operation<
0050         deferred_signatures<Signatures...>, Initiation, InitArgs...>(
0051           deferred_init_tag{},
0052           static_cast<Initiation&&>(initiation),
0053           static_cast<InitArgs&&>(args)...);
0054   }
0055 };
0056 
0057 template <typename Function, typename Signature>
0058 class async_result<deferred_function<Function>, Signature>
0059 {
0060 public:
0061   template <typename Initiation, typename... InitArgs>
0062   static auto initiate(Initiation&& initiation,
0063       deferred_function<Function> token, InitArgs&&... init_args)
0064     -> decltype(
0065         deferred_sequence<
0066           deferred_async_operation<
0067             Signature, Initiation, InitArgs...>,
0068           Function>(deferred_init_tag{},
0069             deferred_async_operation<
0070               Signature, Initiation, InitArgs...>(
0071                 deferred_init_tag{},
0072                 static_cast<Initiation&&>(initiation),
0073                 static_cast<InitArgs&&>(init_args)...),
0074             static_cast<Function&&>(token.function_)))
0075   {
0076     return deferred_sequence<
0077         deferred_async_operation<
0078           Signature, Initiation, InitArgs...>,
0079         Function>(deferred_init_tag{},
0080           deferred_async_operation<
0081             Signature, Initiation, InitArgs...>(
0082               deferred_init_tag{},
0083               static_cast<Initiation&&>(initiation),
0084               static_cast<InitArgs&&>(init_args)...),
0085           static_cast<Function&&>(token.function_));
0086   }
0087 };
0088 
0089 template <typename Function, typename... Signatures>
0090 class async_result<deferred_function<Function>, Signatures...>
0091 {
0092 public:
0093   template <typename Initiation, typename... InitArgs>
0094   static auto initiate(Initiation&& initiation,
0095       deferred_function<Function> token, InitArgs&&... init_args)
0096     -> decltype(
0097         deferred_sequence<
0098           deferred_async_operation<
0099             deferred_signatures<Signatures...>, Initiation, InitArgs...>,
0100           Function>(deferred_init_tag{},
0101             deferred_async_operation<
0102               deferred_signatures<Signatures...>, Initiation, InitArgs...>(
0103                 deferred_init_tag{},
0104                 static_cast<Initiation&&>(initiation),
0105                 static_cast<InitArgs&&>(init_args)...),
0106             static_cast<Function&&>(token.function_)))
0107   {
0108     return deferred_sequence<
0109         deferred_async_operation<
0110           deferred_signatures<Signatures...>, Initiation, InitArgs...>,
0111         Function>(deferred_init_tag{},
0112           deferred_async_operation<
0113             deferred_signatures<Signatures...>, Initiation, InitArgs...>(
0114               deferred_init_tag{},
0115               static_cast<Initiation&&>(initiation),
0116               static_cast<InitArgs&&>(init_args)...),
0117           static_cast<Function&&>(token.function_));
0118   }
0119 };
0120 
0121 template <template <typename, typename> class Associator,
0122     typename Handler, typename Tail, typename DefaultCandidate>
0123 struct associator<Associator,
0124     detail::deferred_sequence_handler<Handler, Tail>,
0125     DefaultCandidate>
0126   : Associator<Handler, DefaultCandidate>
0127 {
0128   static typename Associator<Handler, DefaultCandidate>::type get(
0129       const detail::deferred_sequence_handler<Handler, Tail>& h) noexcept
0130   {
0131     return Associator<Handler, DefaultCandidate>::get(h.handler_);
0132   }
0133 
0134   static auto get(const detail::deferred_sequence_handler<Handler, Tail>& h,
0135       const DefaultCandidate& c) noexcept
0136     -> decltype(Associator<Handler, DefaultCandidate>::get(h.handler_, c))
0137   {
0138     return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
0139   }
0140 };
0141 
0142 #endif // !defined(GENERATING_DOCUMENTATION)
0143 
0144 } // namespace asio
0145 } // namespace boost
0146 
0147 #include <boost/asio/detail/pop_options.hpp>
0148 
0149 #endif // BOOST_ASIO_IMPL_DEFERRED_HPP