Skip to content

Low-risk C++11 and C++14 constexpr functions#177

Merged
lemire merged 4 commits into
fastfloat:mainfrom
leni536:easy-constexpr
Feb 28, 2023
Merged

Low-risk C++11 and C++14 constexpr functions#177
lemire merged 4 commits into
fastfloat:mainfrom
leni536:easy-constexpr

Conversation

@leni536

@leni536 leni536 commented Feb 25, 2023

Copy link
Copy Markdown
Contributor

I added constexpr to functions where the definitions need no or just minimal change.

I added the FASTFLOAT_CONSTEXPR14 to for functions that need at least C++14 to be marked constexpr.

@lemire

lemire commented Feb 25, 2023

Copy link
Copy Markdown
Member

This looks good. Let us run tests.

@lemire

lemire commented Feb 26, 2023

Copy link
Copy Markdown
Member

Running tests.

constexpr static int largest_power_of_five = binary_format<double>::largest_power_of_ten();
constexpr static int number_of_entries = 2 * (largest_power_of_five - smallest_power_of_five + 1);
// Powers of five from 5^-342 all the way to 5^308 rounded toward one.
static const uint64_t power_of_five_128[number_of_entries];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure that the large table is included only once per project. I.e., if several compilation units include our header, we want the large table to appear only once in the final executable or library. That is why we use the strange template construction with an unused parameter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not objecting to the PR. I am just raising a flag.

@lemire

lemire commented Feb 28, 2023

Copy link
Copy Markdown
Member

Ok. I am satisfied that it does not obviously create bloating.

@lemire lemire merged commit 52fed52 into fastfloat:main Feb 28, 2023
@lemire

lemire commented Feb 28, 2023

Copy link
Copy Markdown
Member

Merged.

@leni536 leni536 deleted the easy-constexpr branch March 3, 2023 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants