| 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) |
| Member functions | ||||
strstream::~strstream | ||||
virtual ~strstream(); | (deprecated in C++98) (removed in C++26) | |
Destroys astd::strstream object, which also destroys the memberstd::strstreambuf, which may call the deallocation function if the underlying buffer was dynamically-allocated and not frozen.
(none)
Ifstr() was called on a dynamicstrstream andfreeze(false) was not called after that, this destructor leaks memory.
#include <iostream>#include <strstream> int main(){{std::ostrstream s;// dynamic buffer s<<1.23<<std::ends;std::cout<< s.str()<<'\n'; s.freeze(false);}// destructor called, buffer deallocated {std::ostrstream s; s<<1.23<<std::ends;std::cout<< s.str()<<'\n';// buf.freeze(false);}// destructor called, memory leaked {std::istrstream s("1.23");// constant bufferdouble d; s>> d;std::cout<< d<<'\n';}// destructor called, nothing to deallocate}
Output:
1.231.231.23