std::strstreambuf(3)
π std::strstreambuf π
okay bestie, welcome to the std::strstreambuf(3) page from the C++ Standard Library manual π«Ά this one is giving βvintage C++ buffer energyβ: deprecated, removed, and still fully iconic in a chaotic way πβ¨
πΈ NAME πΈ
std::strstreambuf β std::strstreambuf
β¨ Synopsis β¨
Defined in header <strstream>:
class strstreambuf : public std::basic_streambuf<char>
deprecated in C++98 π¬ removed in C++26 π
std::strstreambuf is a std::basic_streambuf whose associated character sequence is a character array. that array can be:
- constant, like a string literal π
- modifiable but not dynamic, like a stack-allocated array π§
- dynamic, in which case the
std::strstreambufmay be allowed to reallocate the array as necessary to accommodate output, e.g. by callingdelete[]andnew[]or user-provided functions π₯
typical implementation of a std::strstreambuf holds four private data members:
- buffer state, a bitmask type which can represent any combination of the four values
"allocated"(destructor will deallocate),"constant"(output not allowed),"dynamic"(output may reallocate), or"frozen"(deallocation and reallocation are not allowed) π§ - allocated buffer size (the beginning of the buffer does not need a special data member, it may be stored in the inherited pointer
eback()) π - pointer to user-provided allocation function π οΈ
- pointer to user-provided deallocation function π§Ή
π Notes π
after any call to str() on a stream with a dynamic buffer, a call to freeze(false) is required to allow the strstreambuf destructor to deallocate the buffer when necessary π this is the βdo not forget or the vibe check failsβ part.
strstreambuf has been deprecated since C++98 and removed since C++26 π the recommended replacement is std::spanbuf (since C++23) β¨
π Member functions π
Public member functions
constructorβ constructs astrstreambufobject π οΈ (public member function)destructor[virtual]β destructs astrstreambufobject, optionally deallocating the character array π (virtual public member function)freezeβ sets/clears the frozen state of the buffer π§ (public member function)strβ marks the buffer frozen and returns the beginning pointer of the input sequence π«Ά (public member function)pcountβ returns the next pointer minus the beginning pointer in the output sequence: the number of characters written π’ (public member function)
Protected member functions
underflow[virtual]β reads a character from the input sequence without advancing the next pointer π (virtual protected member function)pbackfail[virtual]β backs out the input sequence to unget a character β©οΈ (virtual protected member function)overflow[virtual]β appends a character to the output sequence, may reallocate or initially allocate the buffer if dynamic and not frozen π₯ (virtual protected member function)setbuf[virtual]β attempts to replace the controlled character sequence with an array π§Ί (virtual protected member function)seekoff[virtual]β repositions the next pointer in the input sequence, output sequence, or both, using relative addressing π§ (virtual protected member function)seekpos[virtual]β repositions the next pointer in the input sequence, output sequence, or both using absolute addressing π― (virtual protected member function)
π¦ Inherited from std::basic_streambuf π¦
Member types
char_typeβCharTtraits_typeβTraits; the program is ill-formed ifTraits::char_typeis notCharT.int_typeβTraits::int_typepos_typeβTraits::pos_typeoff_typeβTraits::off_type
Member functions
destructor[virtual]β destructs thebasic_streambufobject π (virtual public member function ofstd::basic_streambuf<CharT,Traits>)
Locales
pubimbueβ invokesimbue()π (public member function ofstd::basic_streambuf<CharT,Traits>)getlocβ obtains a copy of the associated locale πΊοΈ (public member function ofstd::basic_streambuf<CharT,Traits>)
Positioning
pubsetbufβ invokessetbuf()π§Ί (public member function ofstd::basic_streambuf<CharT,Traits>)pubseekoffβ invokesseekoff()π§ (public member function ofstd::basic_streambuf<CharT,Traits>)pubseekposβ invokesseekpos()π― (public member function ofstd::basic_streambuf<CharT,Traits>)pubsyncβ invokessync()π (public member function ofstd::basic_streambuf<CharT,Traits>)
Get area
in_availβ obtains the number of characters immediately available in the get area π (public member function ofstd::basic_streambuf<CharT,Traits>)snextcβ advances the input sequence, then reads one character without advancing again βοΈ (public member function ofstd::basic_streambuf<CharT,Traits>)sbumpcβ reads one character from the input sequence and advances the sequence πΆ (public member function ofstd::basic_streambuf<CharT,Traits>)stossc(removed in C++17) β reads one character from the input sequence and advances the sequence π (public member function ofstd::basic_streambuf<CharT,Traits>)sgetcβ reads one character from the input sequence without advancing the sequence π (public member function ofstd::basic_streambuf<CharT,Traits>)sgetnβ invokesxsgetn()π₯ (public member function ofstd::basic_streambuf<CharT,Traits>)
Put area
sputcβ writes one character to the put area and advances the next pointer βοΈ (public member function ofstd::basic_streambuf<CharT,Traits>)sputnβ invokesxsputn()π€ (public member function ofstd::basic_streambuf<CharT,Traits>)
Putback
sputbackcβ puts one character back in the input sequence β©οΈ (public member function ofstd::basic_streambuf<CharT,Traits>)sungetcβ moves the next pointer in the input sequence back by one βͺ (public member function ofstd::basic_streambuf<CharT,Traits>)
Protected member functions
constructorβ constructs abasic_streambufobject π οΈ (protected member function)operator=(C++11) β replaces abasic_streambufobject π (protected member function)swap(C++11) β swaps twobasic_streambufobjects π (protected member function)
Locales
imbue[virtual]β changes the associated locale π (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)
Positioning
setbuf[virtual]β replaces the buffer with user-defined array, if permitted π§Ί (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)seekoff[virtual]β repositions the next pointer in the input sequence, output sequence, or both, using relative addressing π§ (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)seekpos[virtual]β repositions the next pointer in the input sequence, output sequence, or both using absolute addressing π― (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)sync[virtual]β synchronizes the buffers with the associated character sequence π (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)
Get area
showmanyc[virtual]β obtains the number of characters available for input in the associated input sequence, if known π’ (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)underflow[virtual]β reads characters from the associated input sequence to the get area π (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)uflow[virtual]β reads characters from the associated input sequence to the get area and advances the next pointer πΆ (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)xsgetn[virtual]β reads multiple characters from the input sequence π₯ (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)eback,gptr,egptrβ returns a pointer to the beginning, current character and the end of the get area π§ (protected member function)gbumpβ advances the next pointer in the input sequence βοΈ (protected member function)setgβ repositions the beginning, next, and end pointers of the input sequence π― (protected member function)
Put area
xsputn[virtual]β writes multiple characters to the output sequence π€ (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)overflow[virtual]β writes characters to the associated output sequence from the put area π₯ (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)pbase,pptr,epptrβ returns a pointer to the beginning, current character and the end of the put area π§ (protected member function)pbumpβ advances the next pointer of the output sequence βοΈ (protected member function)setpβ repositions the beginning, next, and end pointers of the output sequence π― (protected member function)
Putback
pbackfail[virtual]β puts a character back into the input sequence, possibly modifying the input sequence β©οΈ (virtual protected member function ofstd::basic_streambuf<CharT,Traits>)
mwah π this page came from http://cppreference.com, dated 2024.06.10, and itβs the std::strstreambuf(3) page β bye bestie, go freeze your buffers responsibly π«Άπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms