Skip to content
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 printf's #58

Open
shindavid opened this issue Apr 14, 2023 · 1 comment
Open

Replace printf's #58

shindavid opened this issue Apr 14, 2023 · 1 comment

Comments

@shindavid
Copy link
Owner

shindavid commented Apr 14, 2023

I learned recently about std::format. It is the true modern replacement to printf() and operator<<. The current codebase has both operator<< usage (via boost logging) and printf() usage, along with some printf()-style custom functions like util::clean_assert() and util::Exception(). All of this should be replaced by std::format.

Note that std::format is a c++20 feature that is at this moment not supported by the latest gcc version (gcc12). While gcc13 advertises std::format support [source].

This humorous blog post clearly demonstrates why std::format is superior to both printf() and std::cout <<.

@shindavid
Copy link
Owner Author

With this change, we should be able to more easily subclass util::Exception. Currently this is cumbersome due to a gcc issue (see here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant