2 // traits/submit_free.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_TRAITS_SUBMIT_FREE_HPP
12 #define BOOST_ASIO_TRAITS_SUBMIT_FREE_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/detail/type_traits.hpp>
21 #if defined(BOOST_ASIO_HAS_DECLTYPE) \
22 && defined(BOOST_ASIO_HAS_NOEXCEPT) \
23 && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
24 # define BOOST_ASIO_HAS_DEDUCED_SUBMIT_FREE_TRAIT 1
25 #endif // defined(BOOST_ASIO_HAS_DECLTYPE)
26 // && defined(BOOST_ASIO_HAS_NOEXCEPT)
27 // && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
29 #include <boost/asio/detail/push_options.hpp>
35 template <typename S, typename R, typename = void>
36 struct submit_free_default;
38 template <typename S, typename R, typename = void>
46 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
47 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false);
50 #if defined(BOOST_ASIO_HAS_DEDUCED_SUBMIT_FREE_TRAIT)
52 template <typename S, typename R, typename = void>
53 struct submit_free_trait : no_submit_free
57 template <typename S, typename R>
58 struct submit_free_trait<S, R,
60 decltype(submit(declval<S>(), declval<R>()))
63 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
65 using result_type = decltype(
66 submit(declval<S>(), declval<R>()));
68 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = noexcept(
69 submit(declval<S>(), declval<R>())));
72 #else // defined(BOOST_ASIO_HAS_DEDUCED_SUBMIT_FREE_TRAIT)
74 template <typename S, typename R, typename = void>
75 struct submit_free_trait :
77 is_same<S, typename remove_reference<S>::type>::value
78 && is_same<R, typename decay<R>::type>::value,
80 is_same<S, typename add_const<S>::type>::value,
82 traits::submit_free<typename add_const<S>::type, R>
85 typename remove_reference<S>::type,
86 typename decay<R>::type>
91 #endif // defined(BOOST_ASIO_HAS_DEDUCED_SUBMIT_FREE_TRAIT)
96 template <typename S, typename R, typename>
97 struct submit_free_default :
98 detail::submit_free_trait<S, R>
102 template <typename S, typename R, typename>
104 submit_free_default<S, R>
108 } // namespace traits
112 #include <boost/asio/detail/pop_options.hpp>
114 #endif // BOOST_ASIO_TRAITS_SUBMIT_FREE_HPP