diff --git a/include/boost/http_proto/fields_view_base.hpp b/include/boost/http_proto/fields_view_base.hpp index ea0cad07..8bf213e3 100644 --- a/include/boost/http_proto/fields_view_base.hpp +++ b/include/boost/http_proto/fields_view_base.hpp @@ -13,9 +13,12 @@ #include #include + +#include #include #include -#include + +#include #include namespace boost { @@ -429,6 +432,42 @@ class fields_view_base core::string_view name) const noexcept; }; +/** Format the container to the output stream + + This function serializes the container to + the specified output stream. + + @par Example + @code + request req; + std::stringstream ss; + ss << req; + assert( ss.str() == "GET / HTTP/1.1\r\n\r\n" ); + @endcode + + @par Effects + @code + return os << f.buffer(); + @endcode + + @par Complexity + Linear in `f.buffer().size()` + + @par Exception Safety + Basic guarantee. + + @return A reference to the output stream, for chaining + + @param os The output stream to write to. + + @param f The container to write. +*/ +BOOST_HTTP_PROTO_DECL +std::ostream& +operator<<( + std::ostream& os, + const fields_view_base& f); + } // http_proto } // boost diff --git a/src/fields_view_base.cpp b/src/fields_view_base.cpp index bd231bd1..49a6d964 100644 --- a/src/fields_view_base.cpp +++ b/src/fields_view_base.cpp @@ -383,5 +383,13 @@ find_all( //------------------------------------------------ +std::ostream& +operator<<( + std::ostream& os, + const fields_view_base& f) +{ + return os << f.buffer(); +} + } // http_proto } // boost