std::basic_streambuf<CharT,Traits>:: ~basic_streambuf
From cppreference.net
<
cpp
|
io
|
basic streambuf
C++
Input/output library
| 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)
|
std::basic_streambuf
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
virtual
~basic_streambuf
(
)
;
|
||
此析构函数不产生实际效果:该
basic_streambuf
的成员(指针和区域设置)将在本析构函数返回后按照常规对象销毁顺序进行析构。但由于其被声明为公开虚函数,使得从
std::basic_streambuf
派生的对象可以通过基类指针进行删除。
目录 |
参数
(无)
示例
运行此代码
#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; // 文件已关闭,输出已刷新并写入 std::ifstream f("test.txt"); std::cout << f.rdbuf(); // 验证 }
输出:
Hello
缺陷报告
以下行为变更缺陷报告被追溯应用于先前发布的C++标准。
| 缺陷报告 | 适用范围 | 发布时行为 | 正确行为 |
|---|---|---|---|
| LWG 54 | C++98 | 未指定析构函数的效果 | 明确为无效果 |
参见
构造
basic_streambuf
对象
(受保护成员函数) |