Skip to content
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

Using C++20 for optimizing compile-time keys #1486

Open
lemire opened this issue Mar 5, 2021 · 1 comment
Open

Using C++20 for optimizing compile-time keys #1486

lemire opened this issue Mar 5, 2021 · 1 comment
Labels
on demand Related to simdjson::ondemand functionality performance

Comments

@lemire
Copy link
Member

lemire commented Mar 5, 2021

We expect that most of the keys are known at compile-time, which you can leverage to validate them.
According to stack overflow, see https://stackoverflow.com/questions/46919582/is-it-possible-to-test-if-a-constexpr-function-is-evaluated-at-compile-time, C++20 solves the problem:

constexpr int foo(int s)
{
    if (std::is_constant_evaluated()) // note: not "if constexpr"
        /* evaluated at compile time */;
    else
        /* evaluated at run time */;
}
@lemire lemire added this to the 2.0 milestone Mar 5, 2021
@jkeiser jkeiser added on demand Related to simdjson::ondemand functionality performance labels Mar 9, 2021
@jkeiser
Copy link
Member

jkeiser commented Mar 9, 2021

I was wondering if there was a way we could use initializer lists and have c++ 11 compatibility, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on demand Related to simdjson::ondemand functionality performance
Projects
None yet
Development

No branches or pull requests

2 participants