// // traits/set_value_member.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef ASIO_TRAITS_SET_VALUE_MEMBER_HPP #define ASIO_TRAITS_SET_VALUE_MEMBER_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" #include "asio/detail/type_traits.hpp" #include "asio/detail/variadic_templates.hpp" #if defined(ASIO_HAS_DECLTYPE) \ && defined(ASIO_HAS_NOEXCEPT) \ && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE) # define ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT 1 #endif // defined(ASIO_HAS_DECLTYPE) // && defined(ASIO_HAS_NOEXCEPT) // && defined(ASIO_HAS_WORKING_EXPRESSION_SFINAE) #include "asio/detail/push_options.hpp" namespace asio { namespace traits { template struct set_value_member_default; template struct set_value_member; } // namespace traits namespace detail { struct no_set_value_member { ASIO_STATIC_CONSTEXPR(bool, is_valid = false); ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); }; #if defined(ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT) template struct set_value_member_trait : no_set_value_member { }; #if defined(ASIO_HAS_VARIADIC_TEMPLATES) template struct set_value_member_trait().set_value(declval()...)) >::type> { ASIO_STATIC_CONSTEXPR(bool, is_valid = true); using result_type = decltype( declval().set_value(declval()...)); ASIO_STATIC_CONSTEXPR(bool, is_noexcept = noexcept( declval().set_value(declval()...))); }; #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) template struct set_value_member_trait().set_value()) >::type> { ASIO_STATIC_CONSTEXPR(bool, is_valid = true); using result_type = decltype(declval().set_value()); ASIO_STATIC_CONSTEXPR(bool, is_noexcept = noexcept(declval().set_value())); }; #define ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF(n) \ template \ struct set_value_member_trait().set_value(ASIO_VARIADIC_DECLVAL(n))) \ >::type> \ { \ ASIO_STATIC_CONSTEXPR(bool, is_valid = true); \ \ using result_type = decltype( \ declval().set_value(ASIO_VARIADIC_DECLVAL(n))); \ \ ASIO_STATIC_CONSTEXPR(bool, is_noexcept = noexcept( \ declval().set_value(ASIO_VARIADIC_DECLVAL(n)))); \ }; \ /**/ ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF) #undef ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) #else // defined(ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT) template struct set_value_member_trait; #if defined(ASIO_HAS_VARIADIC_TEMPLATES) template struct set_value_member_trait : conditional< is_same::type>::value && conjunction::type>...>::value, typename conditional< is_same::type>::value, no_set_value_member, traits::set_value_member::type, void(Vs...)> >::type, traits::set_value_member< typename remove_reference::type, void(typename decay::type...)> >::type { }; #else // defined(ASIO_HAS_VARIADIC_TEMPLATES) template struct set_value_member_trait : conditional< is_same::type>::value, typename conditional< is_same::type>::value, no_set_value_member, traits::set_value_member::type, void()> >::type, traits::set_value_member::type, void()> >::type { }; #define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME(n) \ ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_##n #define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_1 \ && is_same::type>::value #define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_2 \ ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_1 \ && is_same::type>::value #define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_3 \ ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_2 \ && is_same::type>::value #define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_4 \ ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_3 \ && is_same::type>::value #define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_5 \ ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_4 \ && is_same::type>::value #define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_6 \ ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_5 \ && is_same::type>::value #define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_7 \ ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_6 \ && is_same::type>::value #define ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_8 \ ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_7 \ && is_same::type>::value #define ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF(n) \ template \ struct set_value_member_trait : \ conditional< \ is_same::type>::value \ ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME(n), \ typename conditional< \ is_same::type>::value, \ no_set_value_member, \ traits::set_value_member< \ typename add_const::type, \ void(ASIO_VARIADIC_TARGS(n))> \ >::type, \ traits::set_value_member< \ typename remove_reference::type, \ void(ASIO_VARIADIC_DECAY(n))> \ >::type \ { \ }; \ /**/ ASIO_VARIADIC_GENERATE(ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF) #undef ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF #undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME #undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_1 #undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_2 #undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_3 #undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_4 #undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_5 #undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_6 #undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_7 #undef ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_8 #endif // defined(ASIO_HAS_VARIADIC_TEMPLATES) #endif // defined(ASIO_HAS_DEDUCED_SET_VALUE_MEMBER_TRAIT) } // namespace detail namespace traits { template struct set_value_member_default : detail::set_value_member_trait { }; template struct set_value_member : set_value_member_default { }; } // namespace traits } // namespace asio #include "asio/detail/pop_options.hpp" #endif // ASIO_TRAITS_SET_VALUE_MEMBER_HPP