llvm-project
1616fbac - [libc++] Fix checks for terminal and flushes in std::print() (#70321)

Commit
48 days ago
[libc++] Fix checks for terminal and flushes in std::print() (#70321) The check whether a stream is associated with a terminal or not and the flushing of the stream in `std::print()` is needed only on Windows. Additionally, the correct flush should be used. When `std::print` is called with a C stream, `std::fflush()` should be used. When it is called with C++ `ostream`, `ostream::flush()` should be called. Because POSIX does not have a separate Unicode API for terminal output, checking for terminal (`isatty`) and flushing is not needed at all. Moreover, `isatty` has noticeable performance cost. See also https://wg21.link/LWG4044. Fixes #70142
Author
Parents
Loading