From 08c1e93fa36a49f49325a07fe91ff92c964c2b6c Mon Sep 17 00:00:00 2001 From: Chanho Park Date: Thu, 11 Dec 2014 18:55:56 +0900 Subject: Imported Upstream version 1.57.0 --- boost/asio/detail/handler_type_requirements.hpp | 274 +++++++++++++++++------- 1 file changed, 201 insertions(+), 73 deletions(-) (limited to 'boost/asio/detail/handler_type_requirements.hpp') diff --git a/boost/asio/detail/handler_type_requirements.hpp b/boost/asio/detail/handler_type_requirements.hpp index a7f47c2fe4..da111f1de6 100644 --- a/boost/asio/detail/handler_type_requirements.hpp +++ b/boost/asio/detail/handler_type_requirements.hpp @@ -2,7 +2,7 @@ // detail/handler_type_requirements.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 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) @@ -37,13 +37,32 @@ # endif // defined(__GXX_EXPERIMENTAL_CXX0X__) # endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4) # endif // defined(__GNUC__) -# if defined(BOOST_MSVC) +# if defined(BOOST_ASIO_MSVC) # if (_MSC_VER >= 1600) # define BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT 1 # endif // (_MSC_VER >= 1600) -# endif // defined(BOOST_MSVC) +# endif // defined(BOOST_ASIO_MSVC) +# if defined(__clang__) +# if __has_feature(__cxx_static_assert__) +# define BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS_ASSERT 1 +# endif // __has_feature(cxx_static_assert) +# endif // defined(__clang__) #endif // !defined(BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS) +#if defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS) +# include +#endif // defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS) + +// Newer gcc needs special treatment to suppress unused typedef warnings. +#if defined(__GNUC__) +# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4) +# define BOOST_ASIO_UNUSED_TYPEDEF __attribute__((__unused__)) +# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || (__GNUC__ > 4) +#endif // defined(__GNUC__) +#if !defined(BOOST_ASIO_UNUSED_TYPEDEF) +# define BOOST_ASIO_UNUSED_TYPEDEF +#endif // !defined(BOOST_ASIO_UNUSED_TYPEDEF) + namespace boost { namespace asio { namespace detail { @@ -93,6 +112,7 @@ char (&two_arg_handler_test(Handler, ...))[2]; template T& lvref(); template T& lvref(T); +template const T& clvref(); template const T& clvref(T); template char argbyv(T); @@ -104,25 +124,36 @@ struct handler_type_requirements #define BOOST_ASIO_COMPLETION_HANDLER_CHECK( \ handler_type, handler) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void()) asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::zero_arg_handler_test( \ - handler, 0)) == 1, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), 0)) == 1, \ "CompletionHandler type requirements not met") \ \ typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)(), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()(), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_READ_HANDLER_CHECK( \ handler_type, handler) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code, std::size_t)) \ + asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::two_arg_handler_test( \ - handler, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ static_cast(0), \ static_cast(0))) == 1, \ "ReadHandler type requirements not met") \ @@ -130,19 +161,27 @@ struct handler_type_requirements typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)( \ - boost::asio::detail::lvref(), \ - boost::asio::detail::lvref()), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref(), \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF + #define BOOST_ASIO_WRITE_HANDLER_CHECK( \ handler_type, handler) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code, std::size_t)) \ + asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::two_arg_handler_test( \ - handler, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ static_cast(0), \ static_cast(0))) == 1, \ "WriteHandler type requirements not met") \ @@ -150,55 +189,76 @@ struct handler_type_requirements typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)( \ - boost::asio::detail::lvref(), \ - boost::asio::detail::lvref()), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref(), \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_ACCEPT_HANDLER_CHECK( \ handler_type, handler) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code)) \ + asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::one_arg_handler_test( \ - handler, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ static_cast(0))) == 1, \ "AcceptHandler type requirements not met") \ \ typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)( \ - boost::asio::detail::lvref()), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_CONNECT_HANDLER_CHECK( \ handler_type, handler) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code)) \ + asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::one_arg_handler_test( \ - handler, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ static_cast(0))) == 1, \ "ConnectHandler type requirements not met") \ \ typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)( \ - boost::asio::detail::lvref()), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK( \ handler_type, handler, iter_type) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code, iter_type)) \ + asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::two_arg_handler_test( \ - handler, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ static_cast(0), \ static_cast(0))) == 1, \ "ComposedConnectHandler type requirements not met") \ @@ -206,19 +266,26 @@ struct handler_type_requirements typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)( \ - boost::asio::detail::lvref(), \ - boost::asio::detail::lvref()), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref(), \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_RESOLVE_HANDLER_CHECK( \ handler_type, handler, iter_type) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code, iter_type)) \ + asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::two_arg_handler_test( \ - handler, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ static_cast(0), \ static_cast(0))) == 1, \ "ResolveHandler type requirements not met") \ @@ -226,37 +293,51 @@ struct handler_type_requirements typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)( \ - boost::asio::detail::lvref(), \ - boost::asio::detail::lvref()), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref(), \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_WAIT_HANDLER_CHECK( \ handler_type, handler) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code)) \ + asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::one_arg_handler_test( \ - handler, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ static_cast(0))) == 1, \ "WaitHandler type requirements not met") \ \ typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)( \ - boost::asio::detail::lvref()), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_SIGNAL_HANDLER_CHECK( \ handler_type, handler) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code, int)) \ + asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::two_arg_handler_test( \ - handler, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ static_cast(0), \ static_cast(0))) == 1, \ "SignalHandler type requirements not met") \ @@ -264,94 +345,141 @@ struct handler_type_requirements typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)( \ - boost::asio::detail::lvref(), \ - boost::asio::detail::lvref()), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref(), \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_HANDSHAKE_HANDLER_CHECK( \ handler_type, handler) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code)) \ + asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::one_arg_handler_test( \ - handler, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ static_cast(0))) == 1, \ "HandshakeHandler type requirements not met") \ \ typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)( \ - boost::asio::detail::lvref()), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF + +#define BOOST_ASIO_BUFFERED_HANDSHAKE_HANDLER_CHECK( \ + handler_type, handler) \ + \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code, std::size_t)) \ + asio_true_handler_type; \ + \ + BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ + sizeof(boost::asio::detail::two_arg_handler_test( \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ + static_cast(0), \ + static_cast(0))) == 1, \ + "BufferedHandshakeHandler type requirements not met") \ + \ + typedef boost::asio::detail::handler_type_requirements< \ + sizeof( \ + boost::asio::detail::argbyv( \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ + sizeof( \ + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref(), \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_SHUTDOWN_HANDLER_CHECK( \ handler_type, handler) \ \ + typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \ + void(boost::system::error_code)) \ + asio_true_handler_type; \ + \ BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \ sizeof(boost::asio::detail::one_arg_handler_test( \ - handler, \ + boost::asio::detail::clvref< \ + asio_true_handler_type>(), \ static_cast(0))) == 1, \ "ShutdownHandler type requirements not met") \ \ typedef boost::asio::detail::handler_type_requirements< \ sizeof( \ boost::asio::detail::argbyv( \ - boost::asio::detail::clvref(handler))) + \ + boost::asio::detail::clvref< \ + asio_true_handler_type>())) + \ sizeof( \ - boost::asio::detail::lvref(handler)( \ - boost::asio::detail::lvref()), \ - char(0))> + boost::asio::detail::lvref< \ + asio_true_handler_type>()( \ + boost::asio::detail::lvref()), \ + char(0))> BOOST_ASIO_UNUSED_TYPEDEF #else // !defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS) #define BOOST_ASIO_COMPLETION_HANDLER_CHECK( \ handler_type, handler) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_READ_HANDLER_CHECK( \ handler_type, handler) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_WRITE_HANDLER_CHECK( \ handler_type, handler) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_ACCEPT_HANDLER_CHECK( \ handler_type, handler) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_CONNECT_HANDLER_CHECK( \ handler_type, handler) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK( \ handler_type, handler, iter_type) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_RESOLVE_HANDLER_CHECK( \ handler_type, handler, iter_type) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_WAIT_HANDLER_CHECK( \ handler_type, handler) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_SIGNAL_HANDLER_CHECK( \ handler_type, handler) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_HANDSHAKE_HANDLER_CHECK( \ handler_type, handler) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF + +#define BOOST_ASIO_BUFFERED_HANDSHAKE_HANDLER_CHECK( \ + handler_type, handler) \ + typedef int BOOST_ASIO_UNUSED_TYPEDEF #define BOOST_ASIO_SHUTDOWN_HANDLER_CHECK( \ handler_type, handler) \ - typedef int + typedef int BOOST_ASIO_UNUSED_TYPEDEF #endif // !defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS) -- cgit v1.2.3