shindavid / AlphaZeroArcade

8 stars 1 forks source link

Replace printf's #58

Open shindavid opened 1 year ago

shindavid commented 1 year ago

I learned recently about std::format. It is the true modern replacement to printf(). The current codebase has printf() along with some printf()-style custom functions like util::clean_assert() and util::Exception(). These should be replaced.

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

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

shindavid commented 1 year ago

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