1//
2// traits/execute_member.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_TRAITS_EXECUTE_MEMBER_HPP
12#define BOOST_ASIO_TRAITS_EXECUTE_MEMBER_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#if defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
22# define BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT 1
23#endif // defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
24
25#include <boost/asio/detail/push_options.hpp>
26
27namespace boost {
28namespace asio {
29namespace traits {
30
31template <typename T, typename F, typename = void>
32struct execute_member_default;
33
34template <typename T, typename F, typename = void>
35struct execute_member;
36
37} // namespace traits
38namespace detail {
39
40struct no_execute_member
41{
42 static constexpr bool is_valid = false;
43 static constexpr bool is_noexcept = false;
44};
45
46#if defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
47
48template <typename T, typename F, typename = void>
49struct execute_member_trait : no_execute_member
50{
51};
52
53template <typename T, typename F>
54struct execute_member_trait<T, F,
55 void_t<
56 decltype(declval<T>().execute(declval<F>()))
57 >>
58{
59 static constexpr bool is_valid = true;
60
61 using result_type = decltype(
62 declval<T>().execute(declval<F>()));
63
64 static constexpr bool is_noexcept =
65 noexcept(declval<T>().execute(declval<F>()));
66};
67
68#else // defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
69
70template <typename T, typename F, typename = void>
71struct execute_member_trait :
72 conditional_t<
73 is_same<T, decay_t<T>>::value
74 && is_same<F, decay_t<F>>::value,
75 no_execute_member,
76 traits::execute_member<
77 decay_t<T>,
78 decay_t<F>>
79 >
80{
81};
82
83#endif // defined(BOOST_ASIO_HAS_DEDUCED_EXECUTE_MEMBER_TRAIT)
84
85} // namespace detail
86namespace traits {
87
88template <typename T, typename F, typename>
89struct execute_member_default :
90 detail::execute_member_trait<T, F>
91{
92};
93
94template <typename T, typename F, typename>
95struct execute_member :
96 execute_member_default<T, F>
97{
98};
99
100} // namespace traits
101} // namespace asio
102} // namespace boost
103
104#include <boost/asio/detail/pop_options.hpp>
105
106#endif // BOOST_ASIO_TRAITS_EXECUTE_MEMBER_HPP
107

source code of boost/libs/asio/include/boost/asio/traits/execute_member.hpp