std::basic_istream<CharT,Traits>::~basic_istream
来自 cppreference.com
< cpp | io | basic istream
virtual ~basic_istream(); |
||
析构输入流。
[编辑] 注释
此析构函数不会对底层流缓冲区 (rdbuf()
) 执行任何操作:派生输入流(如 std::basic_ifstream 和 std::basic_istringstream)的析构函数负责调用流缓冲区的析构函数。
[编辑] 示例
运行此代码
#include <iostream> #include <sstream> void print_stringbuf(std::streambuf* p) { std::istream buf(p); // buf shares the buffer with s1 int n; buf >> n; std::cout << n; } // calls the destructor of buf. p remains unaffected int main() { std::istringstream s1("10 20"); print_stringbuf(s1.rdbuf()); int n; s1 >> n; std::cout << ',' << n << '\n'; }
输出
10,20