Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::ostrstream::~ostrstream

      From cppreference.com
      <cpp‎ |io‎ |ostrstream
       
       
       
       
      virtual ~ostrstream();
      (deprecated in C++98)
      (removed in C++26)

      Destroys astd::ostrstream object, which also destroys the memberstd::strstreambuf, which may call the deallocation function if the underlying buffer was dynamically-allocated and not frozen.

      [edit]Parameters

      (none)

      [edit]Notes

      Ifstr() was called on a dynamicostrstream andfreeze(false) was not called after that, this destructor leaks memory.

      [edit]Example

      Run this code
      #include <iostream>#include <strstream> int main(){{std::ostrstream s;// dynamic buffer        s<<1.23;std::cout<< s.str()<<'\n';        s.freeze(false);}// destructor called, buffer deallocated {std::ostrstream s;        s<<1.23;std::cout<< s.str()<<'\n';//      buf.freeze(false);}// destructor called, memory leaked}

      Output:

      1.231.23
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/io/ostrstream/%7Eostrstream&oldid=170640"

      [8]ページ先頭

      ©2009-2026 Movatter.jp