From 416f84bc63e256b553911d86b49c8a13b2e433ca Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Fri, 4 May 2018 12:46:49 -0700 Subject: [PATCH] Remove deprecated Body reader and writer ctor signatures --- CHANGELOG.md | 1 + .../boost/beast/http/detail/type_traits.hpp | 16 ---- include/boost/beast/http/impl/parser.ipp | 82 +------------------ include/boost/beast/http/impl/serializer.ipp | 24 +----- include/boost/beast/http/serializer.hpp | 11 +-- include/boost/beast/http/type_traits.hpp | 14 +--- test/beast/http/parser.cpp | 43 ---------- test/beast/http/serializer.cpp | 44 ---------- 8 files changed, 8 insertions(+), 227 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b33e194..3d8cac7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Version 170: * Add test::stream to experimental * Use a shared string for example HTTP server doc roots * Remove deprecated serializer::reader_impl() +* Remove deprecated Body reader and writer ctor signatures -------------------------------------------------------------------------------- diff --git a/include/boost/beast/http/detail/type_traits.hpp b/include/boost/beast/http/detail/type_traits.hpp index 8a6a7df0..b849446b 100644 --- a/include/boost/beast/http/detail/type_traits.hpp +++ b/include/boost/beast/http/detail/type_traits.hpp @@ -194,22 +194,6 @@ struct is_fields_helper : T t10::value && t11::value && t12::value>; }; -template -using has_deprecated_body_writer = - std::integral_constant&>::value && - std::is_constructible&>::value>; - -template -using has_deprecated_body_reader = - std::integral_constant&>::value && - std::is_constructible&>::value>; - } // detail } // http } // beast diff --git a/include/boost/beast/http/impl/parser.ipp b/include/boost/beast/http/impl/parser.ipp index 8a6cab30..45bef1c6 100644 --- a/include/boost/beast/http/impl/parser.ipp +++ b/include/boost/beast/http/impl/parser.ipp @@ -20,25 +20,6 @@ namespace http { template parser:: parser() - : parser{detail::has_deprecated_body_reader{}} -{ -} - -template -parser:: -parser(std::true_type) - : rd_(m_) -{ -#ifndef BOOST_BEAST_ALLOW_DEPRECATED - // Deprecated BodyReader Concept (v1.66) - static_assert(sizeof(Body) == 0, - BOOST_BEAST_DEPRECATION_STRING); -#endif -} - -template -parser:: -parser(std::false_type) : rd_(m_.base(), m_.body()) { } @@ -47,37 +28,8 @@ template template parser:: parser(Arg1&& arg1, ArgN&&... argn) - : parser(std::forward(arg1), - detail::has_deprecated_body_reader{}, - std::forward(argn)...) -{ -} - -// VFALCO arg1 comes before `true_type` to make -// the signature unambiguous. -template -template -parser:: -parser(Arg1&& arg1, std::true_type, ArgN&&... argn) - : m_(std::forward(arg1), - std::forward(argn)...) - , rd_(m_) -{ - m_.clear(); -#ifndef BOOST_BEAST_ALLOW_DEPRECATED - /* Deprecated BodyWriter Concept (v1.66) */ - static_assert(sizeof(Body) == 0, - BOOST_BEAST_DEPRECATION_STRING); -#endif // BOOST_BEAST_ALLOW_DEPRECATED -} - -// VFALCO arg1 comes before `false_type` to make -// the signature unambiguous. -template -template -parser:: -parser(Arg1&& arg1, std::false_type, ArgN&&... argn) - : m_(std::forward(arg1), + : m_( + std::forward(arg1), std::forward(argn)...) , rd_(m_.base(), m_.body()) { @@ -90,36 +42,6 @@ parser:: parser( parser&& other, Args&&... args) - : parser(detail::has_deprecated_body_reader{}, - std::move(other), std::forward(args)...) -{ -} - -template -template -parser:: -parser(std::true_type, - parser&& other, - Args&&... args) - : base_type(std::move(other)) - , m_(other.release(), std::forward(args)...) - , rd_(m_) -{ - if(other.rd_inited_) - BOOST_THROW_EXCEPTION(std::invalid_argument{ - "moved-from parser has a body"}); -#ifndef BOOST_BEAST_ALLOW_DEPRECATED - // Deprecated BodyReader Concept (v1.66) - static_assert(sizeof(Body) == 0, - BOOST_BEAST_DEPRECATION_STRING); -#endif -} - -template -template -parser:: -parser(std::false_type, parser&& other, - Args&&... args) : base_type(std::move(other)) , m_(other.release(), std::forward(args)...) , rd_(m_.base(), m_.body()) diff --git a/include/boost/beast/http/impl/serializer.ipp b/include/boost/beast/http/impl/serializer.ipp index b3785656..b9e7d26b 100644 --- a/include/boost/beast/http/impl/serializer.ipp +++ b/include/boost/beast/http/impl/serializer.ipp @@ -57,34 +57,12 @@ do_visit(error_code& ec, Visit& visit) template< bool isRequest, class Body, class Fields> serializer:: -serializer(value_type& m, std::true_type) - : m_(m) - , wr_(m_) -{ -#ifndef BOOST_BEAST_ALLOW_DEPRECATED - // Deprecated BodyWriter Concept (v1.66) - static_assert(sizeof(Body) == 0, - BOOST_BEAST_DEPRECATION_STRING); -#endif -} - -template< - bool isRequest, class Body, class Fields> -serializer:: -serializer(value_type& m, std::false_type) +serializer(value_type& m) : m_(m) , wr_(m_.base(), m_.body()) { } -template< - bool isRequest, class Body, class Fields> -serializer:: -serializer(value_type& m) - : serializer(m, detail::has_deprecated_body_writer{}) -{ -} - template< bool isRequest, class Body, class Fields> template diff --git a/include/boost/beast/http/serializer.hpp b/include/boost/beast/http/serializer.hpp index e598ad02..352e735f 100644 --- a/include/boost/beast/http/serializer.hpp +++ b/include/boost/beast/http/serializer.hpp @@ -72,17 +72,12 @@ public: using value_type = implementation_defined; #else using value_type = typename std::conditional< - (std::is_constructible&, typename Body::value_type&>::value && ! std::is_constructible const&, - typename Body::value_type const&>::value) || - // Deprecated BodyWriter Concept (v1.66) - (std::is_constructible&>::value && - ! std::is_constructible const&>::value), + typename Body::value_type const&>::value, message, message const>::type; #endif @@ -194,8 +189,6 @@ private: bool header_done_ = false; bool more_; - serializer(value_type& msg, std::true_type); - serializer(value_type& msg, std::false_type); public: /// Constructor serializer(serializer&&) = default; diff --git a/include/boost/beast/http/type_traits.hpp b/include/boost/beast/http/type_traits.hpp index e2cf5215..02211a5c 100644 --- a/include/boost/beast/http/type_traits.hpp +++ b/include/boost/beast/http/type_traits.hpp @@ -95,12 +95,7 @@ struct is_body_writer::value && std::is_constructible&, - typename T::value_type&>::value) || - // Deprecated BodyWriter Concept (v1.66) - (std::is_constructible&>::value && - std::is_constructible&>::value) + typename T::value_type&>::value) ) > {}; #endif @@ -149,12 +144,7 @@ struct is_body_reader::value && std::is_constructible&, - typename T::value_type&>::value) || - // Deprecated BodyReader Concept (v1.66) - (std::is_constructible&>::value && - std::is_constructible&>::value) + typename T::value_type&>::value) > { }; diff --git a/test/beast/http/parser.cpp b/test/beast/http/parser.cpp index 763c9c85..59374565 100644 --- a/test/beast/http/parser.cpp +++ b/test/beast/http/parser.cpp @@ -36,42 +36,6 @@ public: using parser_type = parser; - struct deprecated_body - { - using value_type = std::string; - - class reader - { - public: - template - explicit - reader(message&) - { - } - - void - init(boost::optional const&, error_code& ec) - { - ec = {}; - } - - template - std::size_t - put(ConstBufferSequence const& buffers, error_code& ec) - { - ec = {}; - return boost::asio::buffer_size(buffers); - } - - void - finish(error_code& ec) - { - ec = {}; - } - }; - }; - - static boost::asio::const_buffer buf(string_view s) @@ -379,12 +343,6 @@ public: BEAST_EXPECT(std::distance(m1.begin(), m1.end()) == 0); } - void testBodyReaderCtor() - { - request_parser p; - boost::ignore_unused(p); - } - void run() override { @@ -393,7 +351,6 @@ public: testNeedMore(); testGotSome(); testIssue818(); - testBodyReaderCtor(); } }; diff --git a/test/beast/http/serializer.cpp b/test/beast/http/serializer.cpp index 70405e83..763f5865 100644 --- a/test/beast/http/serializer.cpp +++ b/test/beast/http/serializer.cpp @@ -20,40 +20,6 @@ namespace http { class serializer_test : public beast::unit_test::suite { public: - struct deprecated_body - { - using value_type = std::string; - - class writer - { - public: - using const_buffers_type = - boost::asio::const_buffer; - - value_type const& body_; - - template - explicit - writer(message const& m): - body_{m.body()} - { - } - - void init(error_code& ec) - { - ec.assign(0, ec.category()); - } - - boost::optional> - get(error_code& ec) - { - ec.assign(0, ec.category()); - return {{const_buffers_type{ - body_.data(), body_.size()}, false}}; - } - }; - }; - struct const_body { struct value_type{}; @@ -149,20 +115,10 @@ public: } } - void testBodyWriterCtor() - { - response res; - request req; - serializer sr1{res}; - serializer sr2{req}; - boost::ignore_unused(sr1, sr2); - } - void run() override { testWriteLimit(); - testBodyWriterCtor(); } };