I know it is not possible to overload (stream) operators for primitive types as follows:
std::ostream & operator<<(std::ostream &stream, const double s) {
stream << std::scientific << std::showpos << std::setprecision(15) << std::to_string(s);
return stream;
}
What is the preferred way for defining global formatting options for primitive types? Note that I want to apply the formatting to any kind of output stream, not only specific streams like std::cout. C++11 solutions are welcome. Any hints?
Aucun commentaire:
Enregistrer un commentaire