-
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
Is there a specific reason to not constexprify Dragonbox? #2506
Comments
Since I was responsible for the recently implemented
I don't have a specific reason for this, it was just mentioned by @vitaut that the most feasible approach is to use Dragon4 at compile-time. I agreed with this because Dragonbox FP formatting code seems complicated for me, thus it could have some ideas that cannot be
Sure, but it requires some work, additional work considering choosing the most feasible approach. I'm open to making Dragonbox available at compile-time 😉, but I don't think it would help {fmt} somehow.
Yeah, it's a familiar problem... probably for everyone who tried to make their code |
As I mentioned, I was already able to make Dragonbox @vitaut You can just close this issue, if you don't have further comments.
BTW, yeah, I was also very disappointed with this. Probably because adding static data that is not explicitly asked by the programmer is something compilers are not recommended to do? I don't know. Sounds silly to me to be honest, just like the fact that |
I don't have much to add to what @alexezeder wrote. I think Dragon4 is OK for now but if it proves to be slow in terms of compile time affecting real use cases we could look into ways to optimize it in the future, possibly by constexprifying Dragonbox. |
Is there a specific reason to not
constexpr
ify Dragonbox? If not, I believe it should be not terribly difficult to do so, because as far as I know the only real obstacle is that some intrinsics are notconstexpr
. But we can just wrap those intrinsics withif (!is_constant_evaluated())
and provide fallback implementations along with that. I'm experimenting myself with the recent master branch, and I guess Dragonbox is fine while it fails at this line, I do not know why.Another issue is that the compiler is whining about
static constexpr
tables insideconstexpr
functions beingstatic
. (See e.g., https://stackoverflow.com/questions/62458079/static-constexpr-variables-in-a-constexpr-function.) Honestly I think this is a sort of nonsensical language restriction, but well, it is like that. A simple solution is to move those tables out of the functions.The text was updated successfully, but these errors were encountered: