std::ostrst...~ostrstream(3)
okay bestie, welcome to the C++ Standard Libary page for std::ostrst...~ostrstream(3) β we're talking about the std::ostrstream::~ostrstream destructor, and it's giving legacy-era energy π
β¨
π NAME π
std::ostrstream::~ostrstream β std::ostrstream::~ostrstream
πΈ Synopsis πΈ
virtual ~ostrstream(); (deprecated in C++98)
(removed in C++26)
This destructor destroys a std::ostrstream object, which also destroys the member std::strstreambuf, which may call the deallocation function if the underlying buffer was dynamically-allocated and not frozen. Cleanup when it happens? Iconic. π«Ά
β οΈ Heads up: this is deprecated in C++98 and removed in C++26, so yeah, it's a whole historical artifact, not a main-character modern API.
π Parameters π
(none) β literally zero parameters, bestie. Not a single one. π
π Notes π
If str() was called on a dynamic ostrstream and freeze(false) was not called after that, this destructor leaks memory.
π¨ That is a real memory leak, not a vibe. Do not ignore the freeze(false), queen.
π§ Example π§
// Run this code β go off, bestie:
#include <iostream>
#include <strstream>
int main()
{
{
std::ostrstream s; // dynamic buffer
s << 1.23;
std::cout << s.str() << '\n';
s.freeze(false);
} // destructor called, buffer deallocated
{
std::ostrstream s;
s << 1.23;
std::cout << s.str() << '\n';
// buf.freeze(false);
} // destructor called, memory leaked
}
π Output: π
1.23
1.23
mwah π this page came from http://cppreference.com, dated 2024.06.10, and lives under std::ostrst...~ostrstream(3) β bye bestie, don't leak memory! π«Άβ¨
π¦ 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