From e5a7ff300f44de2e136d6964a9aadb4633cf086b Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 15 Jun 2017 11:03:34 -0700 Subject: [PATCH] Better message formal parameter names fix #476 --- CHANGELOG.md | 1 + include/beast/http/impl/message.ipp | 56 +++++++++++---------- include/beast/http/message.hpp | 76 +++++++++++++++-------------- 3 files changed, 72 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 122506bd..b55afc3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Version 58: * Use static string in basic_fields::reader * Remove redundant code * Fix parsing chunk size with leading zeroes +* Better message formal parameter names API Changes: diff --git a/include/beast/http/impl/message.ipp b/include/beast/http/impl/message.ipp index acd05f1e..45f6774f 100644 --- a/include/beast/http/impl/message.ipp +++ b/include/beast/http/impl/message.ipp @@ -192,8 +192,8 @@ swap( template template message:: -message(header_type&& base, Args&&... args) - : header_type(std::move(base)) +message(header_type&& h, Args&&... args) + : header_type(std::move(h)) , body(std::forward(args)...) { } @@ -201,46 +201,52 @@ message(header_type&& base, Args&&... args) template template message:: -message(header_type const& base, Args&&... args) - : header_type(base) +message(header_type const& h, Args&&... args) + : header_type(h) , body(std::forward(args)...) { } template -template +template message:: -message(U&& u) - : body(std::forward(u)) +message(BodyArg&& body_arg) + : body(std::forward(body_arg)) { } template -template +template message:: -message(U&& u, V&& v) - : header_type(std::forward(v)) - , body(std::forward(u)) +message(BodyArg&& body_arg, HeaderArg&& header_arg) + : header_type(std::forward(header_arg)) + , body(std::forward(body_arg)) { } template -template -message:: -message(std::piecewise_construct_t, std::tuple un) - : message(std::piecewise_construct, un, - beast::detail::make_index_sequence{}) -{ -} - -template -template +template message:: message(std::piecewise_construct_t, - std::tuple&& un, std::tuple&& vn) - : message(std::piecewise_construct, un, vn, - beast::detail::make_index_sequence{}, - beast::detail::make_index_sequence{}) + std::tuple body_args) + : message(std::piecewise_construct, body_args, + beast::detail::make_index_sequence< + sizeof...(BodyArgs)>{}) +{ +} + +template +template +message:: +message(std::piecewise_construct_t, + std::tuple&& body_args, + std::tuple&& header_args) + : message(std::piecewise_construct, + body_args, header_args, + beast::detail::make_index_sequence< + sizeof...(BodyArgs)>{}, + beast::detail::make_index_sequence< + sizeof...(HeaderArgs)>{}) { } diff --git a/include/beast/http/message.hpp b/include/beast/http/message.hpp index 51de591d..f9808dd8 100644 --- a/include/beast/http/message.hpp +++ b/include/beast/http/message.hpp @@ -154,14 +154,14 @@ struct header : Fields // VFALCO Don't move these declarations around, // otherwise the documentation will be wrong. - /** Construct the header. + /** Constructor - All arguments are forwarded to the constructor - of the `fields` member. + @param args Arguments forwarded to the `Fields` + base class constructor. - @note This constructor participates in overload resolution - if and only if the first parameter is not convertible to - `header`. + @note This constructor participates in overload + resolution if and only if the first parameter is + not convertible to @ref header. */ #if BEAST_DOXYGEN template @@ -230,14 +230,14 @@ struct header : Fields /// Copy assignment header& operator=(header const&) = default; - /** Construct the header. + /** Constructor - All arguments are forwarded to the constructor - of the `fields` member. + @param args Arguments forwarded to the `Fields` + base class constructor. - @note This constructor participates in overload resolution - if and only if the first parameter is not convertible to - `header`. + @note This constructor participates in overload + resolution if and only if the first parameter is + not convertible to @ref header. */ template /** Construct a message. - @param u An argument forwarded to the body constructor. + @param body_arg An argument forwarded to the body constructor. @note This constructor participates in overload resolution - only if `u` is not convertible to `header_type`. + only if `body_arg` is not convertible to `header_type`. */ - template::type, header_type>::value>::type + std::decay::type, header_type>::value>::type #endif > explicit - message(U&& u); + message(BodyArg&& body_arg); /** Construct a message. - @param u An argument forwarded to the body constructor. + @param body_arg An argument forwarded to the body constructor. - @param v An argument forwarded to the fields constructor. + @param header_arg An argument forwarded to the header constructor. @note This constructor participates in overload resolution - only if `u` is not convertible to `header_type`. + only if `body_arg` is not convertible to `header_type`. */ - template::type, header_type>::value>::type + ,class = typename std::enable_if< + ! std::is_convertible< + typename std::decay::type, + header_type>::value>::type #endif > - message(U&& u, V&& v); + message(BodyArg&& body_arg, HeaderArg&& header_arg); /** Construct a message. - @param un A tuple forwarded as a parameter pack to the body constructor. + @param body_args A tuple forwarded as a parameter pack to the body constructor. */ - template - message(std::piecewise_construct_t, std::tuple un); - - /** Construct a message. - - @param un A tuple forwarded as a parameter pack to the body constructor. - - @param vn A tuple forwarded as a parameter pack to the fields constructor. - */ - template + template message(std::piecewise_construct_t, - std::tuple&& un, std::tuple&& vn); + std::tuple body_args); + + /** Construct a message. + + @param body_args A tuple forwarded as a parameter pack to the body constructor. + + @param header_args A tuple forwarded as a parameter pack to the fields constructor. + */ + template + message(std::piecewise_construct_t, + std::tuple&& body_args, + std::tuple&& header_args); /// Returns `true` if "close" is specified in the Connection field. bool