Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
cfde93af
Commit
cfde93af
authored
Jun 04, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add FMT_STATIC_CONSTEXPR
parent
986a5a6c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
include/fmt/format.h
include/fmt/format.h
+8
-1
No files found.
include/fmt/format.h
View file @
cfde93af
...
@@ -254,6 +254,13 @@ namespace detail {
...
@@ -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 {
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment