std::basic_...c_streambuf(3)
π NAME π
okay so this is page std::basic_...c_streambuf(3) from the C++ Standard Libary manual, and the star of the show is std::basic_streambuf::~basic_streambuf β also literally std::basic_streambuf::~basic_streambuf, yes bestie, itβs listed twice and weβre keeping both. π
β¨ Synopsis β¨
virtual ~basic_streambuf();
This destructor has no effect: the members of this basic_streambuf β the pointers and the locale β are destructed in accordance with the usual object destruction sequence after this destructor returns. But because itβs declared public virtual, it allows the objects that are derived from std::basic_streambuf to be deleted through a pointer to base class. Thatβs the whole point, no cap. π«Ά
π Parameters π
(none)β nothing to pass in, periodt. π
π§ Example π§
Run this code, bestie:
#include <fstream>
#include <iostream>
int main()
{
std::filebuf* fbp = new std::filebuf;
fbp->open("test.txt", std::ios_base::out);
fbp->sputn("Hello\n", 6);
std::streambuf* sbp = fbp;
delete sbp; // the file is closed, output flushed and written
std::ifstream f("test.txt");
std::cout << f.rdbuf(); // proof
}
π Output π
Hello
π Defect reports π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards. Lowkey iconic paperwork, ngl. π¦
- DR:
LWG 54- Applied to:
C++98 - Behavior as published: the effect of the destructor was not specified
- Correct behavior: specified as no effect
- Applied to:
π See also π
- constructor β constructs a
basic_streambufobject (protected member function) β¨
later bestie π«Ά β source/version/date check: http://cppreference.com, 2024.06.10, page std::basic_...c_streambuf(3) π
π¦ 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