# HG changeset patch # User František Kučera # Date 1543849900 -3600 # Node ID 95e647bf1922d4134ebb710fc151cae8948398b1 # Parent 114521cca04ac000efaa1e2040a98cdf688016ee CLI: untieStdIO() to avoid unwanted implicit flush() calls on std::cout → less write() calls diff -r 114521cca04a -r 95e647bf1922 include/relpipe/cli/CLI.h --- a/include/relpipe/cli/CLI.h Thu Nov 29 22:30:11 2018 +0100 +++ b/include/relpipe/cli/CLI.h Mon Dec 03 16:11:40 2018 +0100 @@ -23,6 +23,7 @@ #include #include #include +#include using namespace std; @@ -69,6 +70,14 @@ static const int EXIT_CODE_UNKNOWN_COMMAND = 4; static const int EXIT_CODE_DATA_ERROR = 5; + /** + * std::cin and std::cout are "tied" by default i.e. reading from std::cin causes flush of the std::cout. + * Call this to "untie" them and have less write() calls (better buffering). + */ + static void untieStdIO() { + std::cin.tie(nullptr); + } + private: int* argc; char*** argv;