In C++, when I do
std::cout << 1.2;
what is the actual chain of functions that are called to actually display the number? I realize this is compiler specific, but I am interested in particular with the Gnu libstdc++ implementation.
In C, calling printf delegates to vfprintf, which through jump tables calls __printf_fp in glibc. I’m looking for an analogous chain in the pure C++ setting.
Clearly, it will call ostream::operator<< first but it may be library specific beyond that. The best way to answer this is to debug into the code and follow the functions as they occur. This will not only tell you what functions are called but tell your about edge cases and error handling that occurs. Looking at the code may help but it is likely convoluted.
Using this code:
… here is what is does in Visual Studio 2012 without the noise:
So most of the work is actually done in the num_put facet, which writes to an iterator for the output stream.