Consider the following code:
#include <iostream>
bool preInit()
{
std::cerr << "Doing preinitialization...\n";
return true;
}
const bool preinitialized=preInit();
int main()
{
std::cerr << "In main()\nPreinitialization has "
<< (preinitialized ? "" : "not ") << "been done\n";
}
Is the use of std::cerr
(and any other facility of the standard C++ library) safe in preInit()
here? Is the library guaranteed to be ready for use before main()
is called, according to the C++ standard?