+
+namespace boost {
+namespace http_proto {
+
+/** A ConstBufferSequence adapter for an owned `std::string`.
+
+ Takes ownership of a `std::string` and exposes
+ it via an interface conforming to the
+ ConstBufferSequence requirements.
+
+ @par Example
+ @code
+ serializer sr(ctx);
+ response res(status::not_found);
+
+ std::string body =
+ "\n"
+ " \n"
+ " 404 Not Found
\n"
+ " Sorry, the page does not exist.
\n"
+ " \n"
+ "\n";
+ sr.start(res, std::move(body));
+ @endcode
+
+ @see
+ @ref serializer.
+*/
+class string_body
+{
+ std::string s_;
+ buffers::const_buffer cb_;
+
+public:
+ /// The type for each buffer.
+ using value_type = buffers::const_buffer;
+
+ /// The type of a const iterator.
+ using const_iterator = buffers::const_buffer const*;
+
+ string_body(
+ string_body&& other) noexcept
+ : s_(std::move(other.s_))
+ , cb_(s_.data(), s_.size())
+ {
+ other.cb_ = {};
+ }
+
+ /** Constructor.
+ */
+ string_body(
+ string_body const& other) = delete;
+
+ /** Constructor.
+
+ @param s The string to take ownership of.
+ */
+ string_body(
+ std::string s) noexcept
+ : s_(std::move(s))
+ , cb_(s_.data(), s_.size())
+ {
+ }
+
+ /** Return an iterator to the beginning of the
+ buffer sequence.
+ */
+ const_iterator
+ begin() const noexcept
+ {
+ return &cb_;
+ }
+
+ /** Return an iterator to the end of the
+ buffer sequence.
+ */
+ const_iterator
+ end() const noexcept
+ {
+ return &cb_ + 1;
+ }
+};
+
+} // http_proto
+} // boost
+
+#endif
diff --git a/include/boost/http_proto/version.hpp b/include/boost/http_proto/version.hpp
index 54a7b668..7cb5a2ca 100644
--- a/include/boost/http_proto/version.hpp
+++ b/include/boost/http_proto/version.hpp
@@ -33,7 +33,7 @@ enum class version : char
*/
BOOST_HTTP_PROTO_DECL
core::string_view
-to_string(version v) noexcept;
+to_string(version v);
/** Format the version to an output stream.
diff --git a/src/field.cpp b/src/field.cpp
index 6bdb98a0..c1c5b64e 100644
--- a/src/field.cpp
+++ b/src/field.cpp
@@ -552,7 +552,7 @@ get_field_table() noexcept
} // detail
core::string_view
-to_string(field f) noexcept
+to_string(field f)
{
auto const& v = detail::get_field_table();
BOOST_ASSERT(static_cast(f) < v.size());
diff --git a/src/version.cpp b/src/version.cpp
index ca904a0c..88e7170c 100644
--- a/src/version.cpp
+++ b/src/version.cpp
@@ -15,7 +15,7 @@ namespace http_proto {
core::string_view
to_string(
- version v) noexcept
+ version v)
{
switch(v)
{