| I/O manipulators | ||||
| Print functions(C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
| Synchronized Output | ||||
(C++20) | ||||
| Types | ||||
| Error category interface | ||||
(C++11) | ||||
(C++11) |
| Public member functions | ||||
| Protected member functions | ||||
strstreambuf::overflow | ||||
protected: virtual int_type overflow( int_type c=EOF); | (deprecated in C++98) (removed in C++26) | |
Appends the characterc to the put area of the buffer, reallocating if possible.
palloc was used in the constructor, that function is called with(*palloc)(n) wheren is the number of bytes to allocate, otherwisenewchar[n] is used. If a pointer to the deallocating functionpfree was used in the constructor, that function is called with(*pfree)(p) to deallocate the previous array, if needed, otherwisedelete[] p is used. If allocation fails, the function fails and returnsEOF.Contents |
| c | - | the character to store in the put area |
Ifc==EOF, returns some value other thanEOF. Otherwise, returns(unsignedchar)(c) on success,EOF on failure.
#include <iostream>#include <strstream> struct mybuf:std::strstreambuf{ int_type overflow(int_type c){std::cout<<"Before overflow(): size of the put area is "<< epptr()-pbase()<<" with "<< epptr()-pptr()<<" write positions available\n"; int_type rc= std::strstreambuf::overflow(c);std::cout<<"After overflow(): size of the put area is "<< epptr()-pbase()<<" with "<< epptr()-pptr()<<" write positions available\n";return rc;}}; int main(){ mybuf sbuf;// read-write dynamic strstreambufstd::iostream stream(&sbuf); stream<<"Sufficiently long string to overflow the initial allocation, at least "<<" on some systems.";}
Possible output:
Before overflow(): size of the put area is 16 with 0 write positions availableAfter overflow(): size of the put area is 32 with 15 write positions availableBefore overflow(): size of the put area is 32 with 0 write positions availableAfter overflow(): size of the put area is 64 with 31 write positions availableBefore overflow(): size of the put area is 64 with 0 write positions availableAfter overflow(): size of the put area is 128 with 63 write positions available
[virtual] | writes characters to the associated output sequence from the put area (virtual protected member function of std::basic_streambuf<CharT,Traits>)[edit] |
[virtual] | appends a character to the output sequence (virtual protected member function of std::basic_stringbuf<CharT,Traits,Allocator>)[edit] |
[virtual] | writes characters to the associated file from the put area (virtual protected member function of std::basic_filebuf<CharT,Traits>)[edit] |
| writes one character to the put area and advances the next pointer (public member function of std::basic_streambuf<CharT,Traits>)[edit] | |
| inserts a character (public member function of std::basic_ostream<CharT,Traits>)[edit] |