diff --git a/CHANGELOG.md b/CHANGELOG.md index f875b2b4..d5e35f4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 214: + +* handler binders use the associated allocator + +-------------------------------------------------------------------------------- + Version 213: * Fix posix_file::close handling of EINTR diff --git a/include/boost/beast/core/detail/bind_handler.hpp b/include/boost/beast/core/detail/bind_handler.hpp index e629faff..108643c2 100644 --- a/include/boost/beast/core/detail/bind_handler.hpp +++ b/include/boost/beast/core/detail/bind_handler.hpp @@ -45,6 +45,9 @@ class bind_wrapper template friend struct net::associated_executor; + template + friend struct net::associated_allocator; + template static typename std::enable_if< @@ -148,31 +151,8 @@ public: mp11::index_sequence_for()); } - // VFALCO I don't think this should be needed, - // please let me know if something breaks. - /* - template - void - operator()(Values&&... values) const - { - invoke(h_, args_, - tuple( - std::forward(values)...), - mp11::index_sequence_for()); - } - */ - // - using allocator_type = - net::associated_allocator_t; - - allocator_type - get_allocator() const noexcept - { - return net::get_associated_allocator(h_); - } - template friend void asio_handler_invoke( @@ -231,6 +211,9 @@ class bind_front_wrapper template friend struct net::associated_executor; + template + friend struct net::associated_allocator; + template void invoke( @@ -266,15 +249,6 @@ public: // - using allocator_type = - net::associated_allocator_t; - - allocator_type - get_allocator() const noexcept - { - return net::get_associated_allocator(h_); - } - template friend void asio_handler_invoke( @@ -320,13 +294,16 @@ template class bind_front_wrapper< Handler, error_code, std::size_t> { - template - friend struct net::associated_executor; - Handler h_; error_code ec_; std::size_t n_; + template + friend struct net::associated_executor; + + template + friend struct net::associated_allocator; + public: using result_type = void; // asio needs this @@ -350,15 +327,6 @@ public: // - using allocator_type = - net::associated_allocator_t; - - allocator_type - get_allocator() const noexcept - { - return net::get_associated_allocator(h_); - } - template friend void asio_handler_invoke( @@ -411,6 +379,9 @@ class bind_back_wrapper template friend struct net::associated_executor; + template + friend struct net::associated_allocator; + template void invoke( @@ -444,15 +415,6 @@ public: // - using allocator_type = - net::associated_allocator_t; - - allocator_type - get_allocator() const noexcept - { - return net::get_associated_allocator(h_); - } - template friend void asio_handler_invoke( @@ -498,13 +460,16 @@ template class bind_back_wrapper< Handler, error_code, std::size_t> { - template - friend struct net::associated_executor; - Handler h_; error_code ec_; std::size_t n_; + template + friend struct net::associated_executor; + + template + friend struct net::associated_allocator; + public: using result_type = void; // asio needs this @@ -528,15 +493,6 @@ public: // - using allocator_type = - net::associated_allocator_t; - - allocator_type - get_allocator() const noexcept - { - return net::get_associated_allocator(h_); - } - template friend void asio_handler_invoke( @@ -595,7 +551,7 @@ struct associated_executor< static type get(beast::detail::bind_wrapper const& op, - Executor const& ex = Executor()) noexcept + Executor const& ex = Executor{}) noexcept { return associated_executor< Handler, Executor>::get(op.h_, ex); @@ -612,7 +568,7 @@ struct associated_executor< static type get(beast::detail::bind_front_wrapper const& op, - Executor const& ex = Executor()) noexcept + Executor const& ex = Executor{}) noexcept { return associated_executor< Handler, Executor>::get(op.h_, ex); @@ -629,13 +585,66 @@ struct associated_executor< static type get(beast::detail::bind_back_wrapper const& op, - Executor const& ex = Executor()) noexcept + Executor const& ex = Executor{}) noexcept { return associated_executor< Handler, Executor>::get(op.h_, ex); } }; +// + +template +struct associated_allocator< + beast::detail::bind_wrapper, Allocator> +{ + using type = typename + associated_allocator::type; + + static + type + get(beast::detail::bind_wrapper const& op, + Allocator const& alloc = Allocator{}) noexcept + { + return associated_allocator< + Handler, Allocator>::get(op.h_, alloc); + } +}; + +template +struct associated_allocator< + beast::detail::bind_front_wrapper, Allocator> +{ + using type = typename + associated_allocator::type; + + static + type + get(beast::detail::bind_front_wrapper const& op, + Allocator const& alloc = Allocator{}) noexcept + { + return associated_allocator< + Handler, Allocator>::get(op.h_, alloc); + } +}; + +template +struct associated_allocator< + beast::detail::bind_back_wrapper, Allocator> +{ + using type = typename + associated_allocator::type; + + static + type + get(beast::detail::bind_back_wrapper const& op, + Allocator const& alloc = Allocator{}) noexcept + { + return associated_allocator< + Handler, Allocator>::get(op.h_, alloc); + } +}; + } // asio } // boost