std::basic_ostream<CharT,Traits>:: ~basic_ostream
From cppreference.net
<
cpp
|
io
|
basic ostream
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_ostream
| Global objects | ||||
| Member functions | ||||
|
basic_ostream::~basic_ostream
|
||||
|
(C++11)
|
||||
| Formatted output | ||||
| Unformatted output | ||||
| Positioning | ||||
| Miscellaneous | ||||
|
(C++11)
|
||||
| Member classes | ||||
| Non-member functions | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
virtual
~basic_ostream
(
)
;
|
||
Destroys the
basic_ostream
object. This destructor does not perform any operation on the underlying streambuffer (
rdbuf()
): the destructors of the derived output streams such as
std::basic_ofstream
and
std::basic_ostringstream
are responsible for calling the destructors of the stream buffers.
Example
Run this code
#include <iostream> #include <sstream> 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 unaffected int main() { std::ostringstream s; s << 42; add_words(s.rdbuf()); s << "."; std::cout << s.str() << '\n'; }
Output:
42 is the answer.