1//
2// execution/executor.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
11#ifndef BOOST_ASIO_EXECUTION_EXECUTOR_HPP
12#define BOOST_ASIO_EXECUTION_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#include <boost/asio/execution/invocable_archetype.hpp>
21#include <boost/asio/traits/equality_comparable.hpp>
22#include <boost/asio/traits/execute_member.hpp>
23
24#if defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT) \
25 && defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
26# define BOOST_ASIO_HAS_DEDUCED_EXECUTION_IS_EXECUTOR_TRAIT 1
27#endif // defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
28 // && defined(BOOST_ASIO_HAS_DEDUCED_EQUALITY_COMPARABLE_TRAIT)
29
30#include <boost/asio/detail/push_options.hpp>
31
32namespace boost {
33namespace asio {
34namespace execution {
35namespace detail {
36
37template <typename T, typename F,
38 typename = void, typename = void, typename = void, typename = void,
39 typename = void, typename = void, typename = void, typename = void>
40struct is_executor_of_impl : false_type
41{
42};
43
44template <typename T, typename F>
45struct is_executor_of_impl<T, F,
46 enable_if_t<
47 traits::execute_member<add_const_t<T>, F>::is_valid
48 >,
49 void_t<
50 result_of_t<decay_t<F>&()>
51 >,
52 enable_if_t<
53 is_constructible<decay_t<F>, F>::value
54 >,
55 enable_if_t<
56 is_move_constructible<decay_t<F>>::value
57 >,
58 enable_if_t<
59 is_nothrow_copy_constructible<T>::value
60 >,
61 enable_if_t<
62 is_nothrow_destructible<T>::value
63 >,
64 enable_if_t<
65 traits::equality_comparable<T>::is_valid
66 >,
67 enable_if_t<
68 traits::equality_comparable<T>::is_noexcept
69 >> : true_type
70{
71};
72
73} // namespace detail
74
75/// The is_executor trait detects whether a type T satisfies the
76/// execution::executor concept.
77/**
78 * Class template @c is_executor is a UnaryTypeTrait that is derived from @c
79 * true_type if the type @c T meets the concept definition for an executor,
80 * otherwise @c false_type.
81 */
82template <typename T>
83struct is_executor :
84#if defined(GENERATING_DOCUMENTATION)
85 integral_constant<bool, automatically_determined>
86#else // defined(GENERATING_DOCUMENTATION)
87 detail::is_executor_of_impl<T, invocable_archetype>
88#endif // defined(GENERATING_DOCUMENTATION)
89{
90};
91
92#if defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
93
94template <typename T>
95constexpr const bool is_executor_v = is_executor<T>::value;
96
97#endif // defined(BOOST_ASIO_HAS_VARIABLE_TEMPLATES)
98
99#if defined(BOOST_ASIO_HAS_CONCEPTS)
100
101template <typename T>
102BOOST_ASIO_CONCEPT executor = is_executor<T>::value;
103
104#define BOOST_ASIO_EXECUTION_EXECUTOR ::boost::asio::execution::executor
105
106#else // defined(BOOST_ASIO_HAS_CONCEPTS)
107
108#define BOOST_ASIO_EXECUTION_EXECUTOR typename
109
110#endif // defined(BOOST_ASIO_HAS_CONCEPTS)
111
112} // namespace execution
113} // namespace asio
114} // namespace boost
115
116#include <boost/asio/detail/pop_options.hpp>
117
118#endif // BOOST_ASIO_EXECUTION_EXECUTOR_HPP
119

source code of boost/libs/asio/include/boost/asio/execution/executor.hpp