std::strstream::~strstream(3)
π std::strstream::~strstream π
β¨ NAME β¨
bestie, this is the C++ Standard Libary manual page for std::strstream::~strstream(3) β the destructor for a std::strstream object. The NAME vibe is literally std::strstream::~strstream β std::strstream::~strstream, no cap. π«Ά
πΈ Synopsis πΈ
virtual ~strstream(); (deprecated in C++98)
(removed in C++26)
So it's a virtual destructor, and it was deprecated in C++98 and removed in C++26. It destroys a std::strstream object, which also destroys the member std::strstreambuf, which may call the deallocation function if the underlying buffer was dynamically-allocated and not frozen. π
π Parameters π
(none)β literally no parameters, not even one, we love a low-effort queen. β¨
π¦ Notes π¦
β οΈ memory leak alert: ifstr()was called on a dynamicstrstreamandfreeze(false)was not called after that, this destructor leaks memory. periodt, that's the whole warning.
π Example π
okay so this example has three little blocks: one clean dealloc, one leaky one, and one constant-buffer βnothing to deallocateβ moment. watch the vibes π
// Run this code
#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 buffer
double d;
s >> d;
std::cout << d << '\n';
} // destructor called, nothing to deallocate
}
β Output β
1.23
1.23
1.23
π«Ά source/version check: http://cppreference.com Β· 2024.06.10 Β· page std::strstream::~strstream(3) β byeee bestie π
π¦ 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