]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/detail/is_executor.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / asio / detail / is_executor.hpp
CommitLineData
b32b8144
FG
1//
2// detail/is_executor.hpp
3// ~~~~~~~~~~~~~~~~~~~~~~
4//
92f5a8d4 5// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
b32b8144
FG
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_DETAIL_IS_EXECUTOR_HPP
12#define BOOST_ASIO_DETAIL_IS_EXECUTOR_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 <boost/asio/detail/type_traits.hpp>
20
21#include <boost/asio/detail/push_options.hpp>
22
23namespace boost {
24namespace asio {
25namespace detail {
26
27struct executor_memfns_base
28{
29 void context();
30 void on_work_started();
31 void on_work_finished();
32 void dispatch();
33 void post();
34 void defer();
35};
36
37template <typename T>
38struct executor_memfns_derived
39 : T, executor_memfns_base
40{
41};
42
43template <typename T, T>
44struct executor_memfns_check
45{
46};
47
48template <typename>
49char (&context_memfn_helper(...))[2];
50
51template <typename T>
52char context_memfn_helper(
53 executor_memfns_check<
54 void (executor_memfns_base::*)(),
55 &executor_memfns_derived<T>::context>*);
56
57template <typename>
58char (&on_work_started_memfn_helper(...))[2];
59
60template <typename T>
61char on_work_started_memfn_helper(
62 executor_memfns_check<
63 void (executor_memfns_base::*)(),
64 &executor_memfns_derived<T>::on_work_started>*);
65
66template <typename>
67char (&on_work_finished_memfn_helper(...))[2];
68
69template <typename T>
70char on_work_finished_memfn_helper(
71 executor_memfns_check<
72 void (executor_memfns_base::*)(),
73 &executor_memfns_derived<T>::on_work_finished>*);
74
75template <typename>
76char (&dispatch_memfn_helper(...))[2];
77
78template <typename T>
79char dispatch_memfn_helper(
80 executor_memfns_check<
81 void (executor_memfns_base::*)(),
82 &executor_memfns_derived<T>::dispatch>*);
83
84template <typename>
85char (&post_memfn_helper(...))[2];
86
87template <typename T>
88char post_memfn_helper(
89 executor_memfns_check<
90 void (executor_memfns_base::*)(),
91 &executor_memfns_derived<T>::post>*);
92
93template <typename>
94char (&defer_memfn_helper(...))[2];
95
96template <typename T>
97char defer_memfn_helper(
98 executor_memfns_check<
99 void (executor_memfns_base::*)(),
100 &executor_memfns_derived<T>::defer>*);
101
102template <typename T>
103struct is_executor_class
104 : integral_constant<bool,
105 sizeof(context_memfn_helper<T>(0)) != 1 &&
106 sizeof(on_work_started_memfn_helper<T>(0)) != 1 &&
107 sizeof(on_work_finished_memfn_helper<T>(0)) != 1 &&
108 sizeof(dispatch_memfn_helper<T>(0)) != 1 &&
109 sizeof(post_memfn_helper<T>(0)) != 1 &&
110 sizeof(defer_memfn_helper<T>(0)) != 1>
111{
112};
113
114template <typename T>
115struct is_executor
116 : conditional<is_class<T>::value,
117 is_executor_class<T>,
118 false_type>::type
119{
120};
121
122} // namespace detail
123} // namespace asio
124} // namespace boost
125
126#include <boost/asio/detail/pop_options.hpp>
127
128#endif // BOOST_ASIO_DETAIL_IS_EXECUTOR_HPP