名前空間
変種
操作

std::basic_ostream<CharT,Traits>::~basic_ostream

提供: cppreference.com
< cpp‎ | io‎ | basic ostream
 
 
 
 
virtual ~basic_ostream();

basic_ostream オブジェクトを破棄します。 このデストラクタはベースとなるストリームバッファ (rdbuf()) に対していかなる操作も行いません。 std::basic_ofstreamstd::basic_ostringstream のような派生出力ストリームクラスのデストラクタがストリームバッファのデストラクタを呼ぶ責任を持ちます。

[編集]

#include <sstream>#include <iostream>void add_words(std::streambuf* p){std::ostream buf(p);// buf shares the buffer with s buf <<" is the answer";}// calls the destructor of buf. p remains unaffectedint main(){std::ostringstream s; s <<42; add_words(s.rdbuf()); s <<".";std::cout<< s.str()<<'\n';}

出力:

42 is the answer.
close