Imagine you have two threads. The first thread tries to print integer as decimal using std::dec:
std::cout << std::dec << 123 << std::endl;
The second thread tries to print integer as hexadecimal using std::hex:
std::cout << std::hex << 0x321 << std::endl;
Is it guaranteed that 123 will be printed as decimal and 0x321 will be printed as hexadecimal? If it is not, how do I do proper std::cout formatting in multithread environment?
C++20 has std::osyncstream. But what can we use before C++20?