Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:02

0001 //
0002 // traits/require_member.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_TRAITS_REQUIRE_MEMBER_HPP
0012 #define BOOST_ASIO_TRAITS_REQUIRE_MEMBER_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/config.hpp>
0019 #include <boost/asio/detail/type_traits.hpp>
0020 
0021 #if defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
0022 # define BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT 1
0023 #endif // defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
0024 
0025 #include <boost/asio/detail/push_options.hpp>
0026 
0027 namespace boost {
0028 namespace asio {
0029 namespace traits {
0030 
0031 template <typename T, typename Property, typename = void>
0032 struct require_member_default;
0033 
0034 template <typename T, typename Property, typename = void>
0035 struct require_member;
0036 
0037 } // namespace traits
0038 namespace detail {
0039 
0040 struct no_require_member
0041 {
0042   static constexpr bool is_valid = false;
0043   static constexpr bool is_noexcept = false;
0044 };
0045 
0046 #if defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
0047 
0048 template <typename T, typename Property, typename = void>
0049 struct require_member_trait : no_require_member
0050 {
0051 };
0052 
0053 template <typename T, typename Property>
0054 struct require_member_trait<T, Property,
0055   void_t<
0056     decltype(declval<T>().require(declval<Property>()))
0057   >>
0058 {
0059   static constexpr bool is_valid = true;
0060 
0061   using result_type = decltype(
0062     declval<T>().require(declval<Property>()));
0063 
0064   static constexpr bool is_noexcept =
0065     noexcept(declval<T>().require(declval<Property>()));
0066 };
0067 
0068 #else // defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
0069 
0070 template <typename T, typename Property, typename = void>
0071 struct require_member_trait :
0072   conditional_t<
0073     is_same<T, decay_t<T>>::value
0074       && is_same<Property, decay_t<Property>>::value,
0075     no_require_member,
0076     traits::require_member<
0077       decay_t<T>,
0078       decay_t<Property>>
0079   >
0080 {
0081 };
0082 
0083 #endif // defined(BOOST_ASIO_HAS_DEDUCED_REQUIRE_MEMBER_TRAIT)
0084 
0085 } // namespace detail
0086 namespace traits {
0087 
0088 template <typename T, typename Property, typename>
0089 struct require_member_default :
0090   detail::require_member_trait<T, Property>
0091 {
0092 };
0093 
0094 template <typename T, typename Property, typename>
0095 struct require_member :
0096   require_member_default<T, Property>
0097 {
0098 };
0099 
0100 } // namespace traits
0101 } // namespace asio
0102 } // namespace boost
0103 
0104 #include <boost/asio/detail/pop_options.hpp>
0105 
0106 #endif // BOOST_ASIO_TRAITS_REQUIRE_MEMBER_HPP