| 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 | ||||
strstreambuf::strstreambuf | ||||
| Protected member functions | ||||
| (1) | ||
explicit strstreambuf(std::streamsize alsize=0); | (deprecated in C++98) (until C++11) | |
strstreambuf(): strstreambuf(0){} explicit strstreambuf(std::streamsize alsize); | (since C++11)(removed in C++26) | |
strstreambuf(void*(*palloc)(std::size_t),void(*pfree)(void*)); | (2) | (deprecated in C++98) (removed in C++26) |
strstreambuf(char* gnext,std::streamsize n,char* pbeg=0); | (3) | (deprecated in C++98) (removed in C++26) |
strstreambuf(signedchar* gnext,std::streamsize n,signedchar* pbeg=0); | (4) | (deprecated in C++98) (removed in C++26) |
strstreambuf(unsignedchar* gnext,std::streamsize n,unsignedchar* pbeg=0); | (5) | (deprecated in C++98) (removed in C++26) |
strstreambuf(constchar* gnext,std::streamsize n); | (6) | (deprecated in C++98) (removed in C++26) |
strstreambuf(constsignedchar* gnext,std::streamsize n); | (7) | (deprecated in C++98) (removed in C++26) |
strstreambuf(constunsignedchar* gnext,std::streamsize n); | (8) | (deprecated in C++98) (removed in C++26) |
std::strstreambuf object: initializes the base class by calling the default constructor ofstd::streambuf, initializes the buffer state to "dynamic" (the buffer will be allocated as needed), initializes allocated size to the providedalsize, initializes the allocation and the deallocation functions to null (will usenew[] anddelete[]).std::strstreambuf object: initializes the base class by calling the default constructor ofstd::streambuf, initializes the buffer state to "dynamic" (the buffer will be allocated as needed), initializes allocated size to unspecified value, initializes the allocation function topalloc and the deallocation function topfree.std::strstreambuf object in following steps:Contents |
| alsize | - | the initial size of the dynamically allocated buffer |
| palloc | - | pointer to user-provided allocation function |
| pfree | - | pointer to user-provided deallocation function |
| gnext | - | pointer to the start of the get area in the user-provided array |
| pbeg | - | pointer to the start of the put area in the user-provided array |
| n | - | the number of bytes in the get area (if pbeg is null) or in the put area (if pbeg is not null) of the user-provided array |
These constructors are typically called by the constructors ofstd::strstream.
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| P0935R0 | C++11 | default constructor was explicit | made implicit |
#include <iostream>#include <strstream> int main(){std::strstreambuf dyn;// dynamicstd::strstream dyn_s;// equivalent stream dyn_s<<1.23<<std::ends;std::cout<< dyn_s.str()<<'\n'; dyn_s.freeze(false); char buf[10];std::strstreambuf user(buf,10, buf);// user-provided output bufferstd::ostrstream user_s(buf,10);// equivalent stream user_s<<1.23<<std::ends;std::cout<< buf<<'\n'; std::strstreambuf lit("1 2 3",5);// constantstd::istrstream lit_s("1 2 3");// equivalent streamint i, j, k; lit_s>> i>> j>> k;std::cout<< i<<' '<< j<<' '<< k<<'\n';}
Output:
1.231.231 2 3
constructs astrstream object, optionally allocating the buffer(public member function of std::strstream)[edit] |