mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Add FMT_STATIC_CONSTEXPR
This commit is contained in:
@ -254,6 +254,13 @@ namespace detail {
|
|||||||
# define FMT_CONSTEXPR20
|
# define FMT_CONSTEXPR20
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Workaround poor codegen in MSVC.
|
||||||
|
#if FMT_MSC_VER
|
||||||
|
# define FMT_STATIC_CONSTEXPR static constexpr
|
||||||
|
#else
|
||||||
|
# define FMT_STATIC_CONSTEXPR constexpr
|
||||||
|
#endif
|
||||||
|
|
||||||
// An equivalent of `*reinterpret_cast<Dest*>(&source)` that doesn't have
|
// An equivalent of `*reinterpret_cast<Dest*>(&source)` that doesn't have
|
||||||
// undefined behavior (e.g. due to type aliasing).
|
// undefined behavior (e.g. due to type aliasing).
|
||||||
// Example: uint64_t d = bit_cast<uint64_t>(2.718);
|
// Example: uint64_t d = bit_cast<uint64_t>(2.718);
|
||||||
@ -1001,7 +1008,7 @@ FMT_CONSTEXPR20 inline auto count_digits(uint32_t n) -> int {
|
|||||||
// An optimization by Kendall Willets from https://bit.ly/3uOIQrB.
|
// An optimization by Kendall Willets from https://bit.ly/3uOIQrB.
|
||||||
// This increments the upper 32 bits (log10(T) - 1) when >= T is added.
|
// This increments the upper 32 bits (log10(T) - 1) when >= T is added.
|
||||||
# define FMT_INC(T) (((sizeof(# T) - 1ull) << 32) - T)
|
# define FMT_INC(T) (((sizeof(# T) - 1ull) << 32) - T)
|
||||||
constexpr uint64_t table[] = {
|
FMT_STATIC_CONSTEXPR uint64_t table[] = {
|
||||||
FMT_INC(0), FMT_INC(0), FMT_INC(0), // 8
|
FMT_INC(0), FMT_INC(0), FMT_INC(0), // 8
|
||||||
FMT_INC(10), FMT_INC(10), FMT_INC(10), // 64
|
FMT_INC(10), FMT_INC(10), FMT_INC(10), // 64
|
||||||
FMT_INC(100), FMT_INC(100), FMT_INC(100), // 512
|
FMT_INC(100), FMT_INC(100), FMT_INC(100), // 512
|
||||||
|
Reference in New Issue
Block a user