23 using base = std::basic_streambuf<Char, Traits>;
24 using view = std::basic_string_view<Char>;
25 using int_type =
typename Traits::int_type;
27 explicit basic_functionbuf(std::function<
void(view)>
const& function) : function(std::move(function)) {
35 std::function<void(view)> function;
37 int_type overflow(int_type c)
override {
38 if (!Traits::eq_int_type(c, Traits::eof())) {
39 *this->pptr() = Traits::to_char_type(c);
42 return sync() ? Traits::not_eof(c) : Traits::eof();
45 int_type sync()
override {
46 if (this->pbase() != this->pptr()) {
47 function(view(this->pbase(), this->pptr()));
48 this->setp(this->pbase(), this->epptr());