std::ostrstream:: ~ostrstream
From cppreference.net
<
cpp
|
io
|
ostrstream
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::ostrstream
| Member functions | ||||
|
ostrstream::~ostrstream
|
||||
|
virtual
~ostrstream
(
)
;
|
(C++98에서 사용 중단됨)
(C++26에서 제거됨) |
|
std::ostrstream 객체를 파괴하며, 이는 멤버 std::strstreambuf 도 함께 파괴합니다. 이로 인해 기본 버퍼가 동적으로 할당되었고 고정되지 않은 경우 할당 해제 함수가 호출될 수 있습니다.
매개변수
(없음)
참고 사항
만약
str()
가 동적
ostrstream
에서 호출되었고,
freeze(false)
가 그 후에 호출되지 않았다면, 이 소멸자는 메모리를 누수합니다.
예제
이 코드 실행
#include <iostream> #include <strstream> int main() { { std::ostrstream s; // 동적 버퍼 s << 1.23; std::cout << s.str() << '\n'; s.freeze(false); } // 소멸자 호출, 버퍼 해제됨 { std::ostrstream s; s << 1.23; std::cout << s.str() << '\n'; // buf.freeze(false); } // 소멸자 호출, 메모리 누수 발생 }
출력:
1.23 1.23