This header file includes <strf.hpp>
namespace strf {

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

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

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 destination<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;
    ~basic_streambuf_writer();

    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

~basic_streambuf_writer();
Effect

Calls recycle()

void recycle() override;
Effects
  • If good() is true then calls dest.sputn(p0, buffer_ptr() - p0), where dest is the reference this object was initialized with, and p0 is the return value of buffer_ptr() 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 buffer_ptr() - p0, calls set_good(false).

  • Calls set_buffer_ptr and/or set_buffer_end.

Postconditions

buffer_space() >= min_destination_buffer_size

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

printing_syntax<DestCreator>, where DestCreator is an implementation-defined type that satifies DestinationCreator.

Return value

An object whose DestCreator object _dest_creator is such that _dest_creator.create() returns

basic_streambuf_writer<CharT, Traits>{dest}