diff --git a/CHANGELOG.md b/CHANGELOG.md index 887bde5e..6fa3cec3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ Version 215: * basic_stream uses boost::shared_ptr +* Remove bind_back_handler -------------------------------------------------------------------------------- diff --git a/doc/qbk/03_core/6_composed.qbk b/doc/qbk/03_core/6_composed.qbk index f73dd279..09e83980 100644 --- a/doc/qbk/03_core/6_composed.qbk +++ b/doc/qbk/03_core/6_composed.qbk @@ -79,7 +79,6 @@ composed operations: be the same as those of the original handler. ]] [[ - [link beast.ref.boost__beast__bind_back_handler `bind_back_handler`] [link beast.ref.boost__beast__bind_front_handler `bind_front_handler`] ][ This function creates a new handler which, when invoked, calls diff --git a/doc/qbk/quickref.xml b/doc/qbk/quickref.xml index 4b963b3e..efcca5f3 100644 --- a/doc/qbk/quickref.xml +++ b/doc/qbk/quickref.xml @@ -63,7 +63,6 @@ allocate_stable 🞲 async_connect 🞲 beast_close_socket 🞲 - bind_back_handler 🞲 bind_front_handler 🞲 bind_handler buffer_size 🞲 diff --git a/doc/qbk/release_notes.qbk b/doc/qbk/release_notes.qbk index 1a9910d0..d0a955f8 100644 --- a/doc/qbk/release_notes.qbk +++ b/doc/qbk/release_notes.qbk @@ -56,7 +56,6 @@ Enlarged scope * Specify exception safety * ([issue 1384]) New functions - `bind_back_handler`, `bind_front_handler` * Better diff --git a/include/boost/beast/core/bind_handler.hpp b/include/boost/beast/core/bind_handler.hpp index 7701dd79..a1cc8b2b 100644 --- a/include/boost/beast/core/bind_handler.hpp +++ b/include/boost/beast/core/bind_handler.hpp @@ -124,59 +124,6 @@ bind_front_handler( std::forward(args)...); } -/** Bind parameters to a completion handler, creating a new handler. - - This function creates a new handler which, when invoked, calls - the original handler with the list of bound arguments. Any - parameters passed in the invocation will be forwarded in - the parameter list before the bound arguments. - - The passed handler and arguments are forwarded into the returned - handler, whose associated allocator and associated executor will - will be the same as those of the original handler. - - @par Example - - This function posts the invocation of the specified completion - handler with bound arguments: - - @code - template - void - signal_unreachable (AsyncReadStream& stream, ReadHandler&& handler) - { - net::post( - stream.get_executor(), - bind_back_handler (std::forward (handler), - net::error::network_unreachable, 0)); - } - @endcode - - @param handler The handler to wrap. - - @param args A list of arguments to bind to the handler. - The arguments are forwarded into the returned object. -*/ -template -#if BOOST_BEAST_DOXYGEN -__implementation_defined__ -#else -auto -#endif -bind_back_handler( - Handler&& handler, - Args&&... args) -> - detail::bind_back_wrapper< - typename std::decay::type, - typename std::decay::type...> -{ - return detail::bind_back_wrapper< - typename std::decay::type, - typename std::decay::type...>( - std::forward(handler), - std::forward(args)...); -} - } // beast } // boost diff --git a/include/boost/beast/core/detail/bind_handler.hpp b/include/boost/beast/core/detail/bind_handler.hpp index 108643c2..915688cd 100644 --- a/include/boost/beast/core/detail/bind_handler.hpp +++ b/include/boost/beast/core/detail/bind_handler.hpp @@ -286,252 +286,6 @@ public: } }; -//------------------------------------------------------------------------------ - -// specialization for the most common case, -// to reduce instantiation time and memory. -template -class bind_front_wrapper< - Handler, error_code, std::size_t> -{ - 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 - - bind_front_wrapper(bind_front_wrapper&&) = default; - bind_front_wrapper(bind_front_wrapper const&) = default; - - template - bind_front_wrapper(DeducedHandler&& handler, - error_code ec, std::size_t n) - : h_(std::forward(handler)) - , ec_(ec) - , n_(n) - { - } - - template - void operator()(Ts&&... ts) - { - h_(ec_, n_, std::forward(ts)...); - } - - // - - template - friend - void asio_handler_invoke( - Function&& f, bind_front_wrapper* op) - { - using net::asio_handler_invoke; - asio_handler_invoke(f, std::addressof(op->h_)); - } - - friend - bool asio_handler_is_continuation( - bind_front_wrapper* op) - { - using net::asio_handler_is_continuation; - return asio_handler_is_continuation( - std::addressof(op->h_)); - } - - friend - void* asio_handler_allocate( - std::size_t size, bind_front_wrapper* op) - { - using net::asio_handler_allocate; - return asio_handler_allocate( - size, std::addressof(op->h_)); - } - - friend - void asio_handler_deallocate( - void* p, std::size_t size, bind_front_wrapper* op) - { - using net::asio_handler_deallocate; - asio_handler_deallocate( - p, size, std::addressof(op->h_)); - } -}; - -//------------------------------------------------------------------------------ -// -// bind_back -// -//------------------------------------------------------------------------------ - -template -class bind_back_wrapper -{ - Handler h_; - detail::tuple args_; - - template - friend struct net::associated_executor; - - template - friend struct net::associated_allocator; - - template - void - invoke( - mp11::index_sequence, - Ts&&... ts) - { - h_( std::forward(ts)..., - detail::get(std::move(args_))...); - } - -public: - using result_type = void; // asio needs this - - bind_back_wrapper(bind_back_wrapper&&) = default; - bind_back_wrapper(bind_back_wrapper const&) = default; - - template - bind_back_wrapper(Handler_&& handler, Args_&&... args) - : h_(std::forward(handler)) - , args_(std::forward(args)...) - { - } - - template - void operator()(Ts&&... ts) - { - invoke( - mp11::index_sequence_for{}, - std::forward(ts)...); - } - - // - - template - friend - void asio_handler_invoke( - Function&& f, bind_back_wrapper* op) - { - using net::asio_handler_invoke; - asio_handler_invoke(f, std::addressof(op->h_)); - } - - friend - bool asio_handler_is_continuation( - bind_back_wrapper* op) - { - using net::asio_handler_is_continuation; - return asio_handler_is_continuation( - std::addressof(op->h_)); - } - - friend - void* asio_handler_allocate( - std::size_t size, bind_back_wrapper* op) - { - using net::asio_handler_allocate; - return asio_handler_allocate( - size, std::addressof(op->h_)); - } - - friend - void asio_handler_deallocate( - void* p, std::size_t size, bind_back_wrapper* op) - { - using net::asio_handler_deallocate; - asio_handler_deallocate( - p, size, std::addressof(op->h_)); - } -}; - -//------------------------------------------------------------------------------ - -// specialization for the most common case, -// to reduce instantiation time and memory. -template -class bind_back_wrapper< - Handler, error_code, std::size_t> -{ - 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 - - bind_back_wrapper(bind_back_wrapper&&) = default; - bind_back_wrapper(bind_back_wrapper const&) = default; - - template - bind_back_wrapper(DeducedHandler&& handler, - error_code ec, std::size_t n) - : h_(std::forward(handler)) - , ec_(ec) - , n_(n) - { - } - - template - void operator()(Ts&&... ts) - { - h_(std::forward(ts)..., ec_, n_); - } - - // - - template - friend - void asio_handler_invoke( - Function&& f, bind_back_wrapper* op) - { - using net::asio_handler_invoke; - asio_handler_invoke(f, std::addressof(op->h_)); - } - - friend - bool asio_handler_is_continuation( - bind_back_wrapper* op) - { - using net::asio_handler_is_continuation; - return asio_handler_is_continuation( - std::addressof(op->h_)); - } - - friend - void* asio_handler_allocate( - std::size_t size, bind_back_wrapper* op) - { - using net::asio_handler_allocate; - return asio_handler_allocate( - size, std::addressof(op->h_)); - } - - friend - void asio_handler_deallocate( - void* p, std::size_t size, bind_back_wrapper* op) - { - using net::asio_handler_deallocate; - asio_handler_deallocate( - p, size, std::addressof(op->h_)); - } -}; - -//------------------------------------------------------------------------------ - } // detail } // beast } // boost @@ -575,23 +329,6 @@ struct associated_executor< } }; -template -struct associated_executor< - beast::detail::bind_back_wrapper, Executor> -{ - using type = typename - associated_executor::type; - - static - type - get(beast::detail::bind_back_wrapper const& op, - Executor const& ex = Executor{}) noexcept - { - return associated_executor< - Handler, Executor>::get(op.h_, ex); - } -}; - // template @@ -628,23 +365,6 @@ struct associated_allocator< } }; -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 @@ -669,11 +389,6 @@ void bind(boost::beast::detail::bind_front_wrapper< Handler, Args...>, ...) = delete; -template -void -bind(boost::beast::detail::bind_back_wrapper< - Handler, Args...>, ...) = delete; - } // std //------------------------------------------------------------------------------ diff --git a/test/beast/core/bind_handler.cpp b/test/beast/core/bind_handler.cpp index ac9e934e..ee4cae42 100644 --- a/test/beast/core/bind_handler.cpp +++ b/test/beast/core/bind_handler.cpp @@ -240,12 +240,6 @@ public: { std::bind(bind_front_handler(test_cb{})); } - - void - failStdBindBack() - { - std::bind(bind_back_handler(test_cb{})); - } #endif //-------------------------------------------------------------------------- @@ -475,92 +469,6 @@ public: } - void - testBindBackHandler() - { - using m1 = move_arg<1>; - using m2 = move_arg<2>; - - // 0-ary - bind_back_handler(test_cb{})(); - - // 1-ary - bind_back_handler(test_cb{}, 42)(); - bind_back_handler(test_cb{})(42); - - // 2-ary - bind_back_handler(test_cb{}, 42, "s")(); - bind_back_handler(test_cb{}, "s")(42); - bind_back_handler(test_cb{})(42, "s"); - - // 3-ary - bind_back_handler(test_cb{}, 42, "s", m1{})(); - bind_back_handler(test_cb{}, m1{})(42, "s"); - bind_back_handler(test_cb{}, "s", m1{})(42); - bind_back_handler(test_cb{})(42, "s", m1{}); - - // 4-ary - bind_back_handler(test_cb{}, 42, "s", m1{}, m2{})(); - bind_back_handler(test_cb{}, "s", m1{}, m2{})(42); - bind_back_handler(test_cb{}, m1{}, m2{})(42, "s"); - bind_back_handler(test_cb{}, "s", m1{}, m2{})(42); - bind_back_handler(test_cb{})(42, "s", m1{}, m2{}); - - error_code ec; - std::size_t n = 256; - - // void(error_code, size_t) - bind_back_handler(test_cb{}, ec, n)(); - - // void(error_code, size_t)(string_view) - bind_back_handler(test_cb{}, "s")(ec, n); - - // perfect forwarding - { - std::shared_ptr const sp = - std::make_shared(42); - bind_back_handler(test_cb{}, sp)(); - BEAST_EXPECT(sp.get() != nullptr); - } - - // associated executor - { - net::io_context ioc; - - testHooks(ioc, bind_back_handler(net::bind_executor( - test_executor(*this, ioc), test_cb{}) - )); - testHooks(ioc, bind_back_handler(net::bind_executor( - test_executor(*this, ioc), test_cb{}), - 42)); - testHooks(ioc, bind_back_handler(net::bind_executor( - test_executor(*this, ioc), test_cb{}), - 42, "s")); - testHooks(ioc, bind_back_handler(net::bind_executor( - test_executor(*this, ioc), test_cb{}), - 42, "s", m1{})); - testHooks(ioc, bind_back_handler(net::bind_executor( - test_executor(*this, ioc), test_cb{}), - 42, "s", m1{}, m2{})); - testHooks(ioc, bind_back_handler(net::bind_executor( - test_executor(*this, ioc), test_cb{}), - ec, n)); - } - - // legacy hooks - legacy_handler::test( - [](legacy_handler h) - { - return bind_back_handler(h); - }); - legacy_handler::test( - [](legacy_handler h) - { - return bind_back_handler( - h, error_code{}, std::size_t{}); - }); - } - //-------------------------------------------------------------------------- template @@ -583,16 +491,6 @@ public: net::error::eof, 0)); } - template - void - signal_unreachable (AsyncReadStream& stream, ReadHandler&& handler) - { - net::post( - stream.get_executor(), - bind_back_handler (std::forward (handler), - net::error::network_unreachable, 0)); - } - void testJavadocs() { @@ -603,10 +501,6 @@ public: BEAST_EXPECT(( &bind_handler_test::signal_eof< test::stream, handler>)); - - BEAST_EXPECT(( - &bind_handler_test::signal_unreachable< - test::stream, handler>)); } //-------------------------------------------------------------------------- @@ -616,7 +510,6 @@ public: { testBindHandler(); testBindFrontHandler(); - testBindBackHandler(); testJavadocs(); } };