-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Basics of formatting at compile-time based on compile-time API #2019
Basics of formatting at compile-time based on compile-time API #2019
Conversation
Since the current CI configuration lacks C++ standards other than C++11 and I was eager to know if it compiles with standards other than C++11, I prepared a special branch to check it on CI, forgot to mention that it has only specific to Linux changes in workflow |
Looks like even gcc-10 with 20 standard works now. Not sure why didn't it work for the first time... |
* `FMT_CONSTEXPR20` defined as `inline` when it cannot be `constexpr` * rename `count_digits_trivial()` to `count_digits_fallback()`
🤨 I don't know what exactly happened to |
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.
Looks great, just one small suggestion to simplify tests.
@vitaut I also remind you that there is a question from me without an answer (#2019 (comment)), this is why I didn't resolve the thread - I fulfilled only one of your points. |
Merged, thanks! |
Since we have the base now, I will try to cover the remaining functionality of the library by following PRs. |
I need to say that this PR does not introduce fully-functioning formatting via {fmt} at compile-time. By fully-functioning I mean that I handled only a few cases (bool, integer, string) of the entire functionality of this library.
This PR based on compile-time API from
compile.h
. This forces end-users to useFMT_COMPILE
macro in cases when formatting should happen at compile-time.compile-test
test case, available only if C++ standard is greater or equal to C++20FMT_CONSTEXPR20
macro definition addedis_constant_evaluated()
function infmt::details
namespace added, that invokesstd::is_constant_evaluated()
if std library has it, otherwise falls back to returningfalse
What functionality of the library is not available at compile-time with this PR:
std::bit_cast
is not available yet, so it's not possible yet