From f8ff44d072803e8c193946818ee7d239c5834b10 Mon Sep 17 00:00:00 2001 From: Mohammad Nejati Date: Fri, 9 Feb 2024 15:41:50 +0000 Subject: [PATCH] Improve documentation of http::serializer Resolves #2221 --- include/boost/beast/http/serializer.hpp | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/include/boost/beast/http/serializer.hpp b/include/boost/beast/http/serializer.hpp index c12bc172..229554dd 100644 --- a/include/boost/beast/http/serializer.hpp +++ b/include/boost/beast/http/serializer.hpp @@ -43,6 +43,14 @@ namespace http { the chunk buffer sequence types @ref chunk_body, @ref chunk_crlf, @ref chunk_header, and @ref chunk_last. + @note + + Moving or copying the serializer after the first call to + @ref serializer::next results in undefined behavior. Try to heap-allocate + the serializer object if you need to move the serializer between multiple + async operations (for example, between a call to `async_write_header` and + `async_write`). + @tparam isRequest `true` if the message is a request. @tparam Body The body type of the message. @@ -189,10 +197,26 @@ private: bool more_ = false; public: - /// Constructor + /** Move Constructor + @note + + Moving or copying the serializer after the first call to + @ref serializer::next results in undefined behavior. Try to heap-allocate + the serializer object if you need to move the serializer between multiple + async operations (for example, between a call to `async_write_header` and + `async_write`). + */ serializer(serializer&&) = default; - /// Constructor + /** Copy Constructor + @note + + Moving or copying the serializer after the first call to + @ref serializer::next results in undefined behavior. Try to heap-allocate + the serializer object if you need to move the serializer between multiple + async operations (for example, between a call to `async_write_header` and + `async_write`). + */ serializer(serializer const&) = default; /// Assignment