This document is still a work in progress.
This header files includes <strf.hpp>
namespace strf {

template <typename CharT, typename Traits = std::char_traits<CharT> >
class basic_streambuf_writer final: public basic_outbuff<CharT>
{ /*...*/ };

using streambuf_writer  = basic_streambuf_writer<char>;
using wstreambuf_writer = basic_streambuf_writer<wchar_t>;

// Destination makers:

template <typename CharT, typename Traits>
/* ... */ to(std::basic_streambuf<CharT, Traits>& dest);

template <typename CharT, typename Traits>
/* ... */ to(std::basic_streambuf<CharT, Traits>* dest);

} // namespace strf

1. Class template basic_streambuf_writer

1.1. Synopsis

namespace strf {

template <typename CharT, typename Traits = std::char_traits<CharT> >
class basic_streambuf_writer final: public basic_outbuff<CharT> {
public:
    explicit basic_streambuf_writer(std::basic_streambuf<CharT, Traits>& dest);
    explicit basic_streambuf_writer(std::basic_streambuf<CharT, Traits>* dest);

    basic_streambuf_writer(const basic_streambuf_writer&) = delete;
    basic_streambuf_writer(basic_streambuf_writer&&) = delete;

    void recycle() override;
    struct result {
        std::streamsize count;
        bool success;
    };
    result finish();
};

// Global type aliases

using streambuf_writer
    = basic_streambuf_writer<char, std::char_traits<char> >;

using wstreambuf_writer
    = basic_streambuf_writer<wchar_t, std::char_traits<wchar_t> >;

} // namespace strf

1.2. Public member functions

void recycle() override;
Effects
  • If good() is true then calls dest.sputn(p0, pointer() - p0), where dest is the reference this object was initialized with, and p0 is the return value of pointer() before any call to advance and advance_to since the last call to recycle(), or since this object’s contruction, whatever happened last.

  • If the returned value of dest.sputn is less then pointer() - p0, calls set_good(false).

  • Calls set_pointer and/or set_end.

Postconditions

size() >= min_size_after_recycle<sizeof(CharT)>()

result finish();
Effects
  • Calls recycle() and set_good(false).

Return value
  • result::count is the sum of the values returned by dest.sputn.

  • result::success is the value good() would return before this call to finish().

2. Function templates to

namespace strf {

template <typename CharT, typename Traits>
/* see below */ to(std::basic_streambuf<CharT, Traits>& dest);

template <typename CharT, typename Traits>
/* see below */ to(std::basic_streambuf<CharT, Traits>* dest);


} // namespace strf
Return type

destination_no_reserve<OBC>, where OBC is an implementation-defined type that satifies OutbuffCreator.

Return value

A destination object whose internal OutbuffCreator object obc is such that obc.create() returns a basic_streambuf_writer<CharT, Traits> object initialized with dest.