-
Notifications
You must be signed in to change notification settings - Fork 472
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
Introduce fmt dependency to simplify string formatting #1139
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PragmaTwice Great Job! It's a really handy and compact way to format strings.
LGTM.
@PragmaTwice Changes are good to me, but we need to update the NOTICE as well. |
Done |
Merging... BTW, NOTICE file can be concise. Depencies' licenses and notices can be simply copied under the |
In this PR, we introduce fmt, the de facto standard of string formatting in C++ and the origin of
std::format
(c++20) &std::print
(c++23), which is also the most popular formatting library in C++, used in softwares likeceph, mariadb, scylladb and mongodb.
And we can replace the old formatting methods (this PR replaced part of them, far from all):
snprintf
or similiar C functions: need to specify types liked
,f
,s
,g
, and hard to format basic types likeuint64_t
(need some ugly macros). cannot format custom types. need to create a fixed-length buffer by our own.std::stringstream
or similiar stream-like C++ types: very slow, and verbose to write.std::to_string
and string concat (like"..." + to_string(num1) + "..." + to_string(num2)
): inefficient, and hard to write & read.fmt is using the MIT license with an exemption clause: https://github.com/fmtlib/fmt/blob/master/LICENSE.rst