Namespaces
Variants
Actions

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

From cppreference.com
< cpp‎ | io‎ | basic istream
 
C++
 
Input/output library
 
std::basic_istream
virtual ~basic_istream();

Destructs the input stream.

[edit] Notes

This destructor does not perform any operation on the underlying streambuffer (rdbuf()): the destructors of the derived input streams such as std::basic_ifstream and std::basic_istringstream are responsible for calling the destructors of the streambuffers.

[edit] Example

#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';
}

Output:

10,20

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