From 7efb6a3ab8cacbc4c75bdb43fd19a99236cd112c Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 19 Sep 2013 21:37:47 -0700 Subject: [PATCH] Reorganize some MPL and Utility classes and files --- Builds/VisualStudio2012/beast.vcxproj | 16 +- Builds/VisualStudio2012/beast.vcxproj.filters | 24 +- beast/MPL.h | 1 + beast/Utility.h | 27 ++ beast/mpl/IsCallPossible.h | 270 ++++++++++++++++++ beast/net/IPEndpoint.h | 1 + beast/net/Net.cpp | 4 +- beast/utility/EnableIf.h | 4 +- .../diagnostic => beast/utility}/Journal.h | 11 +- beast/utility/Utility.cpp | 24 ++ .../utility/impl}/Journal.cpp | 6 + modules/beast_asio/beast_asio.h | 3 + modules/beast_asio/sockets/SocketWrapper.h | 168 +++++------ modules/beast_core/beast_core.cpp | 1 - modules/beast_core/beast_core.h | 1 - modules/beast_core/system/Functional.h | 242 ---------------- 16 files changed, 456 insertions(+), 347 deletions(-) create mode 100644 beast/Utility.h create mode 100644 beast/mpl/IsCallPossible.h rename {modules/beast_core/diagnostic => beast/utility}/Journal.h (97%) create mode 100644 beast/utility/Utility.cpp rename {modules/beast_core/diagnostic => beast/utility/impl}/Journal.cpp (99%) diff --git a/Builds/VisualStudio2012/beast.vcxproj b/Builds/VisualStudio2012/beast.vcxproj index 08e4010356..387b043837 100644 --- a/Builds/VisualStudio2012/beast.vcxproj +++ b/Builds/VisualStudio2012/beast.vcxproj @@ -76,6 +76,7 @@ + @@ -89,7 +90,9 @@ + + @@ -165,7 +168,6 @@ - @@ -367,10 +369,14 @@ true true - + + true + true true + true + true true @@ -597,12 +603,6 @@ true true - - true - true - true - true - true true diff --git a/Builds/VisualStudio2012/beast.vcxproj.filters b/Builds/VisualStudio2012/beast.vcxproj.filters index 7cd3c4e580..c22a2ee528 100644 --- a/Builds/VisualStudio2012/beast.vcxproj.filters +++ b/Builds/VisualStudio2012/beast.vcxproj.filters @@ -201,6 +201,9 @@ {56d34c67-7027-44ba-9f09-4591ce4afb36} + + {775ab0d6-aa5f-43d7-ab3b-3c01652a9ef1} + @@ -1020,9 +1023,6 @@ beast_core\memory - - beast_core\diagnostic - beast_crypto\math @@ -1071,6 +1071,15 @@ beast + + beast\utility + + + beast + + + beast\mpl + @@ -1577,9 +1586,6 @@ beast_core\diagnostic - - beast_core\diagnostic - beast_crypto\math @@ -1595,6 +1601,12 @@ beast\net + + beast\utility + + + beast\utility\impl + diff --git a/beast/MPL.h b/beast/MPL.h index 051931e688..59399ddbd5 100644 --- a/beast/MPL.h +++ b/beast/MPL.h @@ -22,6 +22,7 @@ #include "mpl/AddConst.h" #include "mpl/IfCond.h" +#include "mpl/IsCallPossible.h" #include "mpl/PointerToOther.h" #include "mpl/RemoveConst.h" #include "mpl/RemoveConstVolatile.h" diff --git a/beast/Utility.h b/beast/Utility.h new file mode 100644 index 0000000000..807a251801 --- /dev/null +++ b/beast/Utility.h @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_UTILITY_H_INCLUDED +#define BEAST_UTILITY_H_INCLUDED + +#include "utility/EnableIf.h" +#include "utility/Journal.h" + +#endif + diff --git a/beast/mpl/IsCallPossible.h b/beast/mpl/IsCallPossible.h new file mode 100644 index 0000000000..d6a6ffb108 --- /dev/null +++ b/beast/mpl/IsCallPossible.h @@ -0,0 +1,270 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef BEAST_MPL_ISCALLPOSSIBLE_H_INCLUDED +#define BEAST_MPL_ISCALLPOSSIBLE_H_INCLUDED + +namespace beast { +namespace mpl { + +// inspired by Roman Perepelitsa's presentation from comp.lang.c++.moderated +// based on the implementation here: http://www.rsdn.ru/forum/cpp/2759773.1.aspx +// +namespace is_call_possible_detail +{ + template + struct add_reference + { + typedef T& type; + }; + + template + struct add_reference + { + typedef T& type; + }; + + template class void_exp_result {}; + + template + U const& operator,(U const&, void_exp_result); + + template + U& operator,(U&, void_exp_result); + + template + struct clone_constness + { + typedef dest_type type; + }; + + template + struct clone_constness + { + typedef const dest_type type; + }; +} + +#define BEAST_DEFINE_HAS_MEMBER_FUNCTION(trait_name, member_function_name) \ +template class trait_name; \ + \ +template \ +class trait_name \ +{ \ + class yes { char m; }; \ + class no { yes m[2]; }; \ + struct base_mixin \ + { \ + Result member_function_name(); \ + }; \ + struct base : public T, public base_mixin { private: base(); }; \ + template class helper{}; \ + template \ + static no deduce(U*, helper* = 0); \ + static yes deduce(...); \ +public: \ + static const bool value = sizeof(yes) == sizeof(deduce(static_cast(0))); \ +}; \ + \ +template \ +class trait_name \ +{ \ + class yes { char m; }; \ + class no { yes m[2]; }; \ + struct base_mixin \ + { \ + Result member_function_name(Arg); \ + }; \ + struct base : public T, public base_mixin { private: base(); }; \ + template class helper{}; \ + template \ + static no deduce(U*, helper* = 0); \ + static yes deduce(...); \ +public: \ + static const bool value = sizeof(yes) == sizeof(deduce(static_cast(0))); \ +}; \ + \ +template \ +class trait_name \ +{ \ + class yes { char m; }; \ + class no { yes m[2]; }; \ + struct base_mixin \ + { \ + Result member_function_name(Arg1,Arg2); \ + }; \ + struct base : public T, public base_mixin { private: base(); }; \ + template class helper{}; \ + template \ + static no deduce(U*, helper* = 0); \ + static yes deduce(...); \ +public: \ + static const bool value = sizeof(yes) == sizeof(deduce(static_cast(0))); \ +}; \ + \ +template \ +class trait_name \ +{ \ + class yes { char m; }; \ + class no { yes m[2]; }; \ + struct base_mixin \ + { \ + Result member_function_name(Arg1,Arg2,Arg3); \ + }; \ + struct base : public T, public base_mixin { private: base(); }; \ + template class helper{}; \ + template \ + static no deduce(U*, helper* = 0); \ + static yes deduce(...); \ +public: \ + static const bool value = sizeof(yes) == sizeof(deduce(static_cast(0))); \ +}; \ + \ +template \ +class trait_name \ +{ \ + class yes { char m; }; \ + class no { yes m[2]; }; \ + struct base_mixin \ + { \ + Result member_function_name(Arg1,Arg2,Arg3,Arg4); \ + }; \ + struct base : public T, public base_mixin { private: base(); }; \ + template class helper{}; \ + template \ + static no deduce(U*, helper* = 0); \ + static yes deduce(...); \ +public: \ + static const bool value = sizeof(yes) == sizeof(deduce(static_cast(0))); \ +} + +#define BEAST_DEFINE_IS_CALL_POSSIBLE(trait_name, member_function_name) \ +struct trait_name##_detail \ +{ \ +BEAST_DEFINE_HAS_MEMBER_FUNCTION(has_member, member_function_name); \ +}; \ + \ +template \ +struct trait_name \ +{ \ + private: \ + class yes {}; \ + class no { yes m[2]; }; \ + struct derived : public T \ + { \ + using T::member_function_name; \ + no member_function_name(...) const; \ + private: derived (); \ + }; \ + \ + typedef typename beast::mpl::is_call_possible_detail::clone_constness::type derived_type; \ + \ + template \ + struct return_value_check \ + { \ + static yes deduce(Result); \ + static no deduce(...); \ + static no deduce(no); \ + static no deduce(beast::mpl::is_call_possible_detail::void_exp_result); \ + }; \ + \ + template \ + struct return_value_check \ + { \ + static yes deduce(...); \ + static no deduce(no); \ + }; \ + \ + template \ + struct impl \ + { \ + static const bool value = false; \ + }; \ + \ + template \ + struct impl \ + { \ + static typename beast::mpl::is_call_possible_detail::add_reference::type test_me; \ + static typename beast::mpl::is_call_possible_detail::add_reference::type arg; \ + \ + static const bool value = \ + sizeof( \ + return_value_check::deduce( \ + (test_me.member_function_name(arg), beast::mpl::is_call_possible_detail::void_exp_result()) \ + ) \ + ) == sizeof(yes); \ + }; \ + \ + template \ + struct impl \ + { \ + static typename beast::mpl::is_call_possible_detail::add_reference::type test_me; \ + static typename beast::mpl::is_call_possible_detail::add_reference::type arg1; \ + static typename beast::mpl::is_call_possible_detail::add_reference::type arg2; \ + \ + static const bool value = \ + sizeof( \ + return_value_check::deduce( \ + (test_me.member_function_name(arg1,arg2), beast::mpl::is_call_possible_detail::void_exp_result()) \ + ) \ + ) == sizeof(yes); \ + }; \ + \ + template \ + struct impl \ + { \ + static typename beast::mpl::is_call_possible_detail::add_reference::type test_me; \ + static typename beast::mpl::is_call_possible_detail::add_reference::type arg1; \ + static typename beast::mpl::is_call_possible_detail::add_reference::type arg2; \ + static typename beast::mpl::is_call_possible_detail::add_reference::type arg3; \ + \ + static const bool value = \ + sizeof( \ + return_value_check::deduce( \ + (test_me.member_function_name(arg1,arg2,arg3), beast::mpl::is_call_possible_detail::void_exp_result()) \ + ) \ + ) == sizeof(yes); \ + }; \ + \ + template \ + struct impl \ + { \ + static typename beast::mpl::is_call_possible_detail::add_reference::type test_me; \ + static typename beast::mpl::is_call_possible_detail::add_reference::type arg1; \ + static typename beast::mpl::is_call_possible_detail::add_reference::type arg2; \ + static typename beast::mpl::is_call_possible_detail::add_reference::type arg3; \ + static typename beast::mpl::is_call_possible_detail::add_reference::type arg4; \ + \ + static const bool value = \ + sizeof( \ + return_value_check::deduce( \ + (test_me.member_function_name(arg1,arg2,arg3,arg4), \ + beast::mpl::is_call_possible_detail::void_exp_result()) \ + ) \ + ) == sizeof(yes); \ + }; \ + \ + public: \ + static const bool value = impl::value, Signature>::value; \ +} + +} +} + +#endif diff --git a/beast/net/IPEndpoint.h b/beast/net/IPEndpoint.h index dd292de913..20083c3d75 100644 --- a/beast/net/IPEndpoint.h +++ b/beast/net/IPEndpoint.h @@ -24,6 +24,7 @@ #include #include +#include "../CStdInt.h" #include "../mpl/IfCond.h" namespace beast diff --git a/beast/net/Net.cpp b/beast/net/Net.cpp index e8b3cc9235..e5718bc033 100644 --- a/beast/net/Net.cpp +++ b/beast/net/Net.cpp @@ -19,6 +19,8 @@ #include "BeastConfig.h" -#include "../../modules/beast_core/beast_core.h" +#include "../../modules/beast_core/beast_core.h" // for UnitTest + +#include "../Config.h" #include "impl/IPEndpoint.cpp" diff --git a/beast/utility/EnableIf.h b/beast/utility/EnableIf.h index eca9106d10..51087fa41f 100644 --- a/beast/utility/EnableIf.h +++ b/beast/utility/EnableIf.h @@ -26,10 +26,10 @@ namespace beast { template -struct EnableIfBool : FalseType { typedef T type; }; +struct EnableIfBool : TrueType { typedef T type; }; template -struct EnableIfBool { }; +struct EnableIfBool : FalseType { }; template struct EnableIf : public EnableIfBool { }; diff --git a/modules/beast_core/diagnostic/Journal.h b/beast/utility/Journal.h similarity index 97% rename from modules/beast_core/diagnostic/Journal.h rename to beast/utility/Journal.h index eabe4a542d..7198b0cc04 100644 --- a/modules/beast_core/diagnostic/Journal.h +++ b/beast/utility/Journal.h @@ -17,8 +17,13 @@ */ //============================================================================== -#ifndef BEAST_CORE_JOURNAL_H_INCLUDED -#define BEAST_CORE_JOURNAL_H_INCLUDED +#ifndef BEAST_UTILITY_JOURNAL_H_INCLUDED +#define BEAST_UTILITY_JOURNAL_H_INCLUDED + +#include + +namespace beast +{ /** A generic endpoint for log messages. */ class Journal @@ -158,4 +163,6 @@ private: Journal& operator= (Journal const& other); // disallowed }; +} + #endif diff --git a/beast/utility/Utility.cpp b/beast/utility/Utility.cpp new file mode 100644 index 0000000000..fbfc1450a2 --- /dev/null +++ b/beast/utility/Utility.cpp @@ -0,0 +1,24 @@ +//------------------------------------------------------------------------------ +/* + This file is part of Beast: https://github.com/vinniefalco/Beast + Copyright 2013, Vinnie Falco + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#include "BeastConfig.h" + +#include "../../modules/beast_core/beast_core.h" + +#include "impl/Journal.cpp" diff --git a/modules/beast_core/diagnostic/Journal.cpp b/beast/utility/impl/Journal.cpp similarity index 99% rename from modules/beast_core/diagnostic/Journal.cpp rename to beast/utility/impl/Journal.cpp index 10e0553769..3efc51b212 100644 --- a/modules/beast_core/diagnostic/Journal.cpp +++ b/beast/utility/impl/Journal.cpp @@ -17,6 +17,11 @@ */ //============================================================================== +#include "../Journal.h" + +namespace beast +{ + bool Journal::Sink::active (Severity) { return true; @@ -181,3 +186,4 @@ bool Journal::active (Severity severity) const return m_sink->active (severity); } +} diff --git a/modules/beast_asio/beast_asio.h b/modules/beast_asio/beast_asio.h index 3d514f0fdc..32b41fe8a8 100644 --- a/modules/beast_asio/beast_asio.h +++ b/modules/beast_asio/beast_asio.h @@ -53,6 +53,9 @@ # define BEAST_SOCKET_VIRTUAL #endif +#include "../../beast/MPL.h" +#include "../../beast/Utility.h" + namespace beast { diff --git a/modules/beast_asio/sockets/SocketWrapper.h b/modules/beast_asio/sockets/SocketWrapper.h index b93ee8ea9f..7c80eff28a 100644 --- a/modules/beast_asio/sockets/SocketWrapper.h +++ b/modules/beast_asio/sockets/SocketWrapper.h @@ -51,12 +51,6 @@ namespace detail namespace SocketWrapperMemberChecks { - template - struct EnableIf : boost::false_type { }; - - template <> - struct EnableIf : boost::true_type { }; - BEAST_DEFINE_IS_CALL_POSSIBLE(has_get_io_service, get_io_service); BEAST_DEFINE_IS_CALL_POSSIBLE(has_lowest_layer, lowest_layer); @@ -133,6 +127,12 @@ class SocketWrapper , public Uncopyable { public: + // Converts a static bool constexpr member named 'value' into + // an IntegralConstant for SFINAE overload resolution. + // + template + struct Enabled : public IntegralConstant { }; + template explicit SocketWrapper (Arg& arg) : m_object (arg) @@ -232,11 +232,11 @@ public: { using namespace detail::SocketWrapperMemberChecks; return native_handle (type_name, dest, - EnableIf ::value> ()); + Enabled > ()); } bool native_handle (char const* type_name, void* dest, - boost::true_type) + TrueType) { char const* const name (typeid (typename this_layer_type::native_handle_type).name ()); if (strcmp (name, type_name) == 0) @@ -249,7 +249,7 @@ public: } bool native_handle (char const*, void*, - boost::false_type) + FalseType) { pure_virtual_called (__FILE__, __LINE__); return false; @@ -266,21 +266,21 @@ public: // Apparently has_get_io_service always results in false using namespace detail::SocketWrapperMemberChecks; return get_io_service ( - EnableIf ::value> ()); + Enabled > ()); #else - return get_io_service (boost::true_type ()); + return get_io_service (TrueType ()); #endif } boost::asio::io_service& get_io_service ( - boost::true_type) + TrueType) { return m_object.get_io_service (); } boost::asio::io_service& get_io_service ( - boost::false_type) + FalseType) { pure_virtual_called (__FILE__, __LINE__); return *static_cast (nullptr); @@ -334,11 +334,11 @@ public: { using namespace detail::SocketWrapperMemberChecks; return lowest_layer_ptr (type_name, - EnableIf ::value> ()); + Enabled > ()); } void* lowest_layer_ptr (char const* type_name, - boost::true_type) const + TrueType) const { char const* const name (typeid (typename this_layer_type::lowest_layer_type).name ()); if (strcmp (name, type_name) == 0) @@ -347,7 +347,7 @@ public: } void* lowest_layer_ptr (char const*, - boost::false_type) const + FalseType) const { pure_virtual_called (__FILE__, __LINE__); return nullptr; @@ -359,18 +359,18 @@ public: { using namespace detail::SocketWrapperMemberChecks; return cancel (ec, - EnableIf ::value> ()); + Enabled > ()); } error_code cancel (error_code& ec, - boost::true_type) + TrueType) { return m_object.cancel (ec); } error_code cancel (error_code& ec, - boost::false_type) + FalseType) { return pure_virtual_error (ec, __FILE__, __LINE__); } @@ -381,19 +381,19 @@ public: { using namespace detail::SocketWrapperMemberChecks; return shutdown (what, ec, - EnableIf ::value> ()); + Enabled > ()); } error_code shutdown (shutdown_type what, error_code& ec, - boost::true_type) + TrueType) { return m_object.shutdown (what, ec); } error_code shutdown (shutdown_type, error_code& ec, - boost::false_type) + FalseType) { return pure_virtual_error (ec, __FILE__, __LINE__); } @@ -404,18 +404,18 @@ public: { using namespace detail::SocketWrapperMemberChecks; return close (ec, - EnableIf ::value> ()); + Enabled > ()); } error_code close (error_code& ec, - boost::true_type) + TrueType) { return m_object.close (ec); } error_code close (error_code& ec, - boost::false_type) + FalseType) { return pure_virtual_error (ec, __FILE__, __LINE__); } @@ -430,12 +430,12 @@ public: using namespace detail::SocketWrapperMemberChecks; typedef typename native_socket ::socket_type socket_type; return accept (peer, ec, - EnableIf ::value> ()); + Enabled > ()); } error_code accept (Socket& peer, error_code& ec, - boost::true_type) + TrueType) { using namespace detail::SocketWrapperMemberChecks; return m_object.accept ( @@ -443,7 +443,7 @@ public: } error_code accept (Socket&, error_code& ec, - boost::false_type) + FalseType) { return pure_virtual_error (ec, __FILE__, __LINE__); } @@ -455,12 +455,12 @@ public: using namespace detail::SocketWrapperMemberChecks; typedef typename native_socket ::socket_type socket_type; async_accept (peer, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler), - EnableIf ::value> ()); + Enabled > ()); } void async_accept (Socket& peer, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::true_type) + TrueType) { using namespace detail::SocketWrapperMemberChecks; m_object.async_accept ( @@ -469,7 +469,7 @@ public: } void async_accept (Socket&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::false_type) + FalseType) { get_io_service ().wrap ( BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)) @@ -485,20 +485,20 @@ public: { using namespace detail::SocketWrapperMemberChecks; return read_some (buffers, ec, - EnableIf ::value> ()); + Enabled > ()); } template std::size_t read_some (MutableBufferSequence const& buffers, error_code& ec, - boost::true_type) + TrueType) { return m_object.read_some (buffers, ec); } template std::size_t read_some (MutableBufferSequence const&, error_code& ec, - boost::false_type) + FalseType) { pure_virtual_called (__FILE__, __LINE__); ec = pure_virtual_error (); @@ -511,20 +511,20 @@ public: { using namespace detail::SocketWrapperMemberChecks; return write_some (buffers, ec, - EnableIf ::value> ()); + Enabled > ()); } template std::size_t write_some (ConstBufferSequence const& buffers, error_code& ec, - boost::true_type) + TrueType) { return m_object.write_some (buffers, ec); } template std::size_t write_some (ConstBufferSequence const&, error_code& ec, - boost::false_type) + FalseType) { pure_virtual_called (__FILE__, __LINE__); ec = pure_virtual_error (); @@ -537,13 +537,13 @@ public: { using namespace detail::SocketWrapperMemberChecks; async_read_some (buffers, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler), - EnableIf ::value> ()); + Enabled > ()); } void async_read_some (MutableBuffers const& buffers, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::true_type) + TrueType) { m_object.async_read_some (buffers, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)); @@ -551,7 +551,7 @@ public: void async_read_some (MutableBuffers const&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::false_type) + FalseType) { get_io_service ().wrap ( BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)) @@ -564,13 +564,13 @@ public: { using namespace detail::SocketWrapperMemberChecks; async_write_some (buffers, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler), - EnableIf ::value> ()); + Enabled > ()); } void async_write_some (ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::true_type) + TrueType) { m_object.async_write_some (buffers, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)); @@ -578,7 +578,7 @@ public: void async_write_some (ConstBuffers const&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::false_type) + FalseType) { get_io_service ().wrap ( BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)) @@ -624,11 +624,11 @@ public: { using namespace detail::SocketWrapperMemberChecks; return next_layer_ptr (type_name, - EnableIf ::value> ()); + Enabled > ()); } void* next_layer_ptr (char const* type_name, - boost::true_type) const + TrueType) const { char const* const name (typeid (typename this_layer_type::next_layer_type).name ()); if (strcmp (name, type_name) == 0) @@ -637,7 +637,7 @@ public: } void* next_layer_ptr (char const*, - boost::false_type) const + FalseType) const { pure_virtual_called (__FILE__, __LINE__); return nullptr; @@ -661,19 +661,19 @@ public: { using namespace detail::SocketWrapperMemberChecks; set_verify_mode (verify_mode, - EnableIf ::value> ()); + Enabled > ()); } void set_verify_mode (int verify_mode, - boost::true_type) + TrueType) { m_object.set_verify_mode (verify_mode); } void set_verify_mode (int, - boost::false_type) + FalseType) { pure_virtual_called (__FILE__, __LINE__); } @@ -684,18 +684,18 @@ public: { using namespace detail::SocketWrapperMemberChecks; return handshake (type, ec, - EnableIf ::value> ()); + Enabled > ()); } error_code handshake (handshake_type type, error_code& ec, - boost::true_type) + TrueType) { return m_object.handshake (type, ec); } error_code handshake (handshake_type, error_code& ec, - boost::false_type) + FalseType) { return pure_virtual_error (ec, __FILE__, __LINE__); } @@ -706,20 +706,20 @@ public: { using namespace detail::SocketWrapperMemberChecks; async_handshake (type, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler), - EnableIf ::value> ()); + Enabled > ()); } void async_handshake (handshake_type type, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::true_type) + TrueType) { m_object.async_handshake (type, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)); } void async_handshake (handshake_type, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::false_type) + FalseType) { get_io_service ().wrap ( BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)) @@ -735,19 +735,19 @@ public: { using namespace detail::SocketWrapperMemberChecks; return handshake (type, buffers, ec, - EnableIf ::value> ()); + Enabled > ()); } error_code handshake (handshake_type type, ConstBuffers const& buffers, error_code& ec, - boost::true_type) + TrueType) { return m_object.handshake (type, buffers, ec); } error_code handshake (handshake_type, ConstBuffers const&, error_code& ec, - boost::false_type) + FalseType) { return pure_virtual_error (ec, __FILE__, __LINE__); } @@ -760,14 +760,14 @@ public: using namespace detail::SocketWrapperMemberChecks; async_handshake (type, buffers, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler), - EnableIf ::value> ()); + BOOST_ASIO_MOVE_ARG(SharedHandlerPtr))> > ()); } void async_handshake (handshake_type type, ConstBuffers const& buffers, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::true_type) + TrueType) { m_object.async_handshake (type, buffers, BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)); @@ -775,7 +775,7 @@ public: void async_handshake (handshake_type, ConstBuffers const&, BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::false_type) + FalseType) { get_io_service ().wrap ( BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)) @@ -790,18 +790,18 @@ public: { using namespace detail::SocketWrapperMemberChecks; return shutdown (ec, - EnableIf ::value> ()); + Enabled > ()); } error_code shutdown (error_code& ec, - boost::true_type) + TrueType) { return m_object.shutdown (ec); } error_code shutdown (error_code& ec, - boost::false_type) + FalseType) { return pure_virtual_error (ec, __FILE__, __LINE__); } @@ -812,19 +812,19 @@ public: { using namespace detail::SocketWrapperMemberChecks; async_shutdown (BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler), - EnableIf ::value> ()); + Enabled > ()); } void async_shutdown (BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::true_type) + TrueType) { m_object.async_shutdown ( BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)); } void async_shutdown (BOOST_ASIO_MOVE_ARG(SharedHandlerPtr) handler, - boost::false_type) + FalseType) { get_io_service ().wrap ( BOOST_ASIO_MOVE_CAST(SharedHandlerPtr)(handler)) diff --git a/modules/beast_core/beast_core.cpp b/modules/beast_core/beast_core.cpp index a3f1ab4c0d..f585d9ac36 100644 --- a/modules/beast_core/beast_core.cpp +++ b/modules/beast_core/beast_core.cpp @@ -147,7 +147,6 @@ namespace beast #include "diagnostic/SemanticVersion.cpp" #include "diagnostic/UnitTest.cpp" #include "diagnostic/UnitTestUtilities.cpp" -#include "diagnostic/Journal.cpp" #include "files/DirectoryIterator.cpp" #include "files/File.cpp" diff --git a/modules/beast_core/beast_core.h b/modules/beast_core/beast_core.h index 2e63e5f9d0..727149d13b 100644 --- a/modules/beast_core/beast_core.h +++ b/modules/beast_core/beast_core.h @@ -144,7 +144,6 @@ namespace beast #include "text/String.h" #include "time/AtExitHook.h" #include "diagnostic/LeakChecked.h" -#include "diagnostic/Journal.h" #include "time/RelativeTime.h" #include "time/Time.h" #include "memory/HeapBlock.h" diff --git a/modules/beast_core/system/Functional.h b/modules/beast_core/system/Functional.h index 7788e04e8e..173b93519b 100644 --- a/modules/beast_core/system/Functional.h +++ b/modules/beast_core/system/Functional.h @@ -22,248 +22,6 @@ //------------------------------------------------------------------------------ -// inspired by Roman Perepelitsa's presentation from comp.lang.c++.moderated -// based on the implementation here: http://www.rsdn.ru/forum/cpp/2759773.1.aspx -// -namespace is_call_possible_detail -{ - template - struct add_reference - { - typedef T& type; - }; - - template - struct add_reference - { - typedef T& type; - }; - - template class void_exp_result {}; - - template - U const& operator,(U const&, void_exp_result); - - template - U& operator,(U&, void_exp_result); - - template - struct clone_constness - { - typedef dest_type type; - }; - - template - struct clone_constness - { - typedef const dest_type type; - }; -} - -#define BEAST_DEFINE_HAS_MEMBER_FUNCTION(trait_name, member_function_name) \ -template class trait_name; \ - \ -template \ -class trait_name \ -{ \ - class yes { char m; }; \ - class no { yes m[2]; }; \ - struct base_mixin \ - { \ - Result member_function_name(); \ - }; \ - struct base : public T, public base_mixin { private: base(); }; \ - template class helper{}; \ - template \ - static no deduce(U*, helper* = 0); \ - static yes deduce(...); \ -public: \ - static const bool value = sizeof(yes) == sizeof(deduce(static_cast(0))); \ -}; \ - \ -template \ -class trait_name \ -{ \ - class yes { char m; }; \ - class no { yes m[2]; }; \ - struct base_mixin \ - { \ - Result member_function_name(Arg); \ - }; \ - struct base : public T, public base_mixin { private: base(); }; \ - template class helper{}; \ - template \ - static no deduce(U*, helper* = 0); \ - static yes deduce(...); \ -public: \ - static const bool value = sizeof(yes) == sizeof(deduce(static_cast(0))); \ -}; \ - \ -template \ -class trait_name \ -{ \ - class yes { char m; }; \ - class no { yes m[2]; }; \ - struct base_mixin \ - { \ - Result member_function_name(Arg1,Arg2); \ - }; \ - struct base : public T, public base_mixin { private: base(); }; \ - template class helper{}; \ - template \ - static no deduce(U*, helper* = 0); \ - static yes deduce(...); \ -public: \ - static const bool value = sizeof(yes) == sizeof(deduce(static_cast(0))); \ -}; \ - \ -template \ -class trait_name \ -{ \ - class yes { char m; }; \ - class no { yes m[2]; }; \ - struct base_mixin \ - { \ - Result member_function_name(Arg1,Arg2,Arg3); \ - }; \ - struct base : public T, public base_mixin { private: base(); }; \ - template class helper{}; \ - template \ - static no deduce(U*, helper* = 0); \ - static yes deduce(...); \ -public: \ - static const bool value = sizeof(yes) == sizeof(deduce(static_cast(0))); \ -}; \ - \ -template \ -class trait_name \ -{ \ - class yes { char m; }; \ - class no { yes m[2]; }; \ - struct base_mixin \ - { \ - Result member_function_name(Arg1,Arg2,Arg3,Arg4); \ - }; \ - struct base : public T, public base_mixin { private: base(); }; \ - template class helper{}; \ - template \ - static no deduce(U*, helper* = 0); \ - static yes deduce(...); \ -public: \ - static const bool value = sizeof(yes) == sizeof(deduce(static_cast(0))); \ -} - -#define BEAST_DEFINE_IS_CALL_POSSIBLE(trait_name, member_function_name) \ -struct trait_name##_detail \ -{ \ -BEAST_DEFINE_HAS_MEMBER_FUNCTION(has_member, member_function_name); \ -}; \ - \ -template \ -struct trait_name \ -{ \ - private: \ - class yes {}; \ - class no { yes m[2]; }; \ - struct derived : public T \ - { \ - using T::member_function_name; \ - no member_function_name(...) const; \ - private: derived (); \ - }; \ - \ - typedef typename is_call_possible_detail::clone_constness::type derived_type; \ - \ - template \ - struct return_value_check \ - { \ - static yes deduce(Result); \ - static no deduce(...); \ - static no deduce(no); \ - static no deduce(is_call_possible_detail::void_exp_result); \ - }; \ - \ - template \ - struct return_value_check \ - { \ - static yes deduce(...); \ - static no deduce(no); \ - }; \ - \ - template \ - struct impl \ - { \ - static const bool value = false; \ - }; \ - \ - template \ - struct impl \ - { \ - static typename is_call_possible_detail::add_reference::type test_me; \ - static typename is_call_possible_detail::add_reference::type arg; \ - \ - static const bool value = \ - sizeof( \ - return_value_check::deduce( \ - (test_me.member_function_name(arg), is_call_possible_detail::void_exp_result()) \ - ) \ - ) == sizeof(yes); \ - }; \ - \ - template \ - struct impl \ - { \ - static typename is_call_possible_detail::add_reference::type test_me; \ - static typename is_call_possible_detail::add_reference::type arg1; \ - static typename is_call_possible_detail::add_reference::type arg2; \ - \ - static const bool value = \ - sizeof( \ - return_value_check::deduce( \ - (test_me.member_function_name(arg1,arg2), is_call_possible_detail::void_exp_result()) \ - ) \ - ) == sizeof(yes); \ - }; \ - \ - template \ - struct impl \ - { \ - static typename is_call_possible_detail::add_reference::type test_me; \ - static typename is_call_possible_detail::add_reference::type arg1; \ - static typename is_call_possible_detail::add_reference::type arg2; \ - static typename is_call_possible_detail::add_reference::type arg3; \ - \ - static const bool value = \ - sizeof( \ - return_value_check::deduce( \ - (test_me.member_function_name(arg1,arg2,arg3), is_call_possible_detail::void_exp_result()) \ - ) \ - ) == sizeof(yes); \ - }; \ - \ - template \ - struct impl \ - { \ - static typename is_call_possible_detail::add_reference::type test_me; \ - static typename is_call_possible_detail::add_reference::type arg1; \ - static typename is_call_possible_detail::add_reference::type arg2; \ - static typename is_call_possible_detail::add_reference::type arg3; \ - static typename is_call_possible_detail::add_reference::type arg4; \ - \ - static const bool value = \ - sizeof( \ - return_value_check::deduce( \ - (test_me.member_function_name(arg1,arg2,arg3,arg4), is_call_possible_detail::void_exp_result()) \ - ) \ - ) == sizeof(yes); \ - }; \ - \ - public: \ - static const bool value = impl::value, Signature>::value; \ -} - -//------------------------------------------------------------------------------ - /* Brings functional support into our namespace, based on environment. Notes on bind