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 |
vitaut
left a comment
There was a problem hiding this comment.
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_COMPILEmacro in cases when formatting should happen at compile-time.compile-testtest case, available only if C++ standard is greater or equal to C++20FMT_CONSTEXPR20macro definition addedis_constant_evaluated()function infmt::detailsnamespace added, that invokesstd::is_constant_evaluated()if std library has it, otherwise falls back to returningfalseWhat functionality of the library is not available at compile-time with this PR:
std::bit_castis not available yet, so it's not possible yet