joboccara / NamedType

Implementation of strong types in C++
MIT License
766 stars 85 forks source link

Undesirable inclusion of `<iostream>` for freestanding compilers #57

Closed simvv-exe closed 3 years ago

simvv-exe commented 3 years ago

It is an undesirable to include <iostream> for freestanding compilers. This is especially true for embedded devices that do not have a cout. As you can see in this example https://godbolt.org/z/8vrdv8 call to std::ios_base::Init::Init() cannot be optimized even if you dont use cout and even at maximum optimization level. But this is still add overhead by increasing compilation time, producing larger binaries and increasing startup time.

CelticMinstrel commented 2 years ago

Note: I think you only need <ostream> and not <iostream>. You might even be able to get away with just <iosfwd>.