-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace #include <iostream> with #include <ostream> #5
Conversation
"Significant size" applies to my use case, which is embedded firmware. We have ~512 KB of Flash for the whole binary, and including iostream adds ~220 KB by itself, which is a show-stopper. Basically, any library that includes iostream is unusable for my platform (and likely most embedded platforms). |
Thanks for the feedback. Wouldn't it then even make more sense to include instead of ? Another option would be to template the ostream, but I guess that might be overkill? For my main usecase I always needed std::cout so I included iostream directly, but it would not be a big hassle to change to iosfwd. That being said I would have to adapt some examples and the godbolt links so that everything still compiles and the test suite is ok. |
This makes sense. I know for me, adding another include to my application for I can also update the examples/godbolt links as well. Let me know what works for you! Also, thanks for making this library! |
Alright I will accept your PR if you fix the examples and godbolt links. I actually wanted to say (iny my comment above) that we could also just include iosfwd instead of ostream? |
Including iostream also pulls in locale and other static data that adds significant size to the compiled binary. Since tser only uses ostream, replace `#include <iostream>` with `#include <ostream>` to make tser usable in applications that are sensitive to binary size. Another option would be to `#include <iosfwd>` instead, but that would require all clients to then `#include <ostream>` themselves. This commit also updates the examples, and the Compiler Explorer links/examples in the documentation.
OK! I've updated the Compiler Explorer examples, updated their links in the README, updated the README code, and updated the non-single header version. While we could For the examples, I think it makes sense for the main.cpp to Let me know how this looks! |
Looks good to me now! Thanks for your contribution. |
Including iostream also pulls in locale and other static data that adds
significant size to the compiled binary.
Since tser only uses ostream, replace
#include <iostream>
with#include <ostream>
to make tser usable in applications that aresensitive to binary size.