Namespaces
Variants
Actions

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

From cppreference.com
< cpp‎ | io‎ | basic ostream
 
C++
 
Input/output library
 
std::basic_ostream
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.

[edit] Example

#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.

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant