std::basic_ostream<CharT,Traits>:: flush
|
basic_ostream
&
flush
(
)
;
|
||
커밋되지 않은 변경 사항을 기본 출력 시퀀스에 기록합니다. UnformattedOutputFunction 으로 동작합니다.
만약 rdbuf() 가 널 포인터라면, sentry 객체는 생성되지 않습니다.
그렇지 않으면, sentry 객체를 구성하고 확인한 후 rdbuf ( ) - > pubsync ( ) 를 호출합니다. 호출이 - 1 을 반환하면 setstate ( badbit ) 를 호출합니다.
목차 |
반환값
* this
예외
std::ios_base::failure 를 던질 수 있습니다. 만약 ( exceptions ( ) & badbit ) ! = 0 인 경우.
예제
#include <chrono> #include <iostream> #include <thread> using namespace std::chrono_literals; void f() { std::cout << "Output from thread... "; for (int i{1}; i != 10; ++i) { std::this_thread::sleep_for(250ms); std::cout << i << ' '; // output three numbers at once; // the effect is observable only in real-time if (0 == (i % 3)) std::cout.flush(); } std::cout << std::endl; // flushes as well } int main() { std::thread tr{f}; std::this_thread::sleep_for(150ms); std::clog << "Output from main\n"; tr.join(); }
출력:
Output from main Output from thread... 1 2 3 4 5 6 7 8 9
결함 보고서
다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.
| DR | 적용 대상 | 게시된 동작 | 올바른 동작 |
|---|---|---|---|
| LWG 581 | C++98 |
flush()
가
UnformattedOutputFunction
으로 동작하지 않음
( LWG 이슈 60 의 해결로 인해) |
UnformattedOutputFunction 으로 동작 |
참고 항목
|
sync
(
)
를 호출합니다
(
std::basic_streambuf<CharT,Traits>
의 public 멤버 함수)
|
|
|
[virtual]
|
버퍼를 연관된 문자 시퀀스와 동기화합니다
(
std::basic_streambuf<CharT,Traits>
의 virtual protected 멤버 함수)
|
|
출력 스트림을 플러시합니다
(함수 템플릿) |
|
|
'
\n
'
를 출력하고 출력 스트림을 플러시합니다
(함수 템플릿) |
|
|
기본 저장 장치와 동기화합니다
(
std::basic_istream<CharT,Traits>
의 public 멤버 함수)
|