// // traits/set_value_free.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 BOOST_ASIO_TRAITS_SET_VALUE_FREE_HPP #define BOOST_ASIO_TRAITS_SET_VALUE_FREE_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include #include #include #if defined(BOOST_ASIO_HAS_DECLTYPE) \ && defined(BOOST_ASIO_HAS_NOEXCEPT) \ && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE) # define BOOST_ASIO_HAS_DEDUCED_SET_VALUE_FREE_TRAIT 1 #endif // defined(BOOST_ASIO_HAS_DECLTYPE) // && defined(BOOST_ASIO_HAS_NOEXCEPT) // && defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE) #include namespace boost { namespace asio { namespace traits { template struct set_value_free_default; template struct set_value_free; } // namespace traits namespace detail { struct no_set_value_free { BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = false); BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = false); }; #if defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_FREE_TRAIT) template struct set_value_free_trait : no_set_value_free { }; #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) template struct set_value_free_trait(), declval()...)) >::type> { BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); using result_type = decltype( set_value(declval(), declval()...)); BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = noexcept( set_value(declval(), declval()...))); }; #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) template struct set_value_free_trait())) >::type> { BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); using result_type = decltype(set_value(declval())); BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = noexcept(set_value(declval()))); }; #define BOOST_ASIO_PRIVATE_SET_VALUE_FREE_TRAIT_DEF(n) \ template \ struct set_value_free_trait(), BOOST_ASIO_VARIADIC_DECLVAL(n))) \ >::type> \ { \ BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true); \ \ using result_type = decltype( \ set_value(declval(), BOOST_ASIO_VARIADIC_DECLVAL(n))); \ \ BOOST_ASIO_STATIC_CONSTEXPR(bool, is_noexcept = noexcept( \ set_value(declval(), BOOST_ASIO_VARIADIC_DECLVAL(n)))); \ }; \ /**/ BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SET_VALUE_FREE_TRAIT_DEF) #undef BOOST_ASIO_PRIVATE_SET_VALUE_FREE_TRAIT_DEF #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) #else // defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_FREE_TRAIT) template struct set_value_free_trait; #if defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) template struct set_value_free_trait : conditional< is_same::type>::value && conjunction::type>...>::value, typename conditional< is_same::type>::value, no_set_value_free, traits::set_value_free::type, void(Vs...)> >::type, traits::set_value_free< typename remove_reference::type, void(typename decay::type...)> >::type { }; #else // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) template struct set_value_free_trait : conditional< is_same::type>::value, typename conditional< is_same::type>::value, no_set_value_free, traits::set_value_free::type, void()> >::type, traits::set_value_free::type, void()> >::type { }; #define BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME(n) \ BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_##n #define BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_1 \ && is_same::type>::value #define BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_2 \ BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_1 \ && is_same::type>::value #define BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_3 \ BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_2 \ && is_same::type>::value #define BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_4 \ BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_3 \ && is_same::type>::value #define BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_5 \ BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_4 \ && is_same::type>::value #define BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_6 \ BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_5 \ && is_same::type>::value #define BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_7 \ BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_6 \ && is_same::type>::value #define BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_8 \ BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_7 \ && is_same::type>::value #define BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF(n) \ template \ struct set_value_free_trait : \ conditional< \ is_same::type>::value \ BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME(n), \ typename conditional< \ is_same::type>::value, \ no_set_value_free, \ traits::set_value_free< \ typename add_const::type, \ void(BOOST_ASIO_VARIADIC_TARGS(n))> \ >::type, \ traits::set_value_free< \ typename remove_reference::type, \ void(BOOST_ASIO_VARIADIC_DECAY(n))> \ >::type \ { \ }; \ /**/ BOOST_ASIO_VARIADIC_GENERATE(BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF) #undef BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_TRAIT_DEF #undef BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME #undef BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_1 #undef BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_2 #undef BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_3 #undef BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_4 #undef BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_5 #undef BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_6 #undef BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_7 #undef BOOST_ASIO_PRIVATE_SET_VALUE_MEMBER_IS_SAME_8 #endif // defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES) #endif // defined(BOOST_ASIO_HAS_DEDUCED_SET_VALUE_FREE_TRAIT) } // namespace detail namespace traits { template struct set_value_free_default : detail::set_value_free_trait { }; template struct set_value_free : set_value_free_default { }; } // namespace traits } // namespace asio } // namespace boost #include #endif // BOOST_ASIO_TRAITS_SET_VALUE_FREE_HPP