Simdutf is now constexpr!
I have spent the christmas holidays implementing constexpr support in simdutf. It is now possible to validate and convert text between different encodings such as UTF-8/16/32 at compile time.
Never heard of simdutf? It is an open source C++ library which is used under the hood by Chrome, Safari and other projects.
The cool thing is that the API is the same. It all hinges on the C++23 consteval feature. Here is what the usage may look like:
This makes writing unit tests so nice - instant feedback in the IDE and if it compiles, it means the unit test passed, you don't even have to run it.
Here is a simplified version of what the implementation looks like:
The function declared on row 430 is the existing pointer based api which internally dispatches to the best supported SIMD backend. If using the span api on row 433, different things happen if the function is evaluated at compile time or runtime. There is no runtime penalty for this dispatch between compile and runtime, it all happens during compilation.
So, what about compile times, since more of the implementation now has to be included in the header file? Not so bad, this costs around 3%.
Ja, när man får till något hyggligt komplicerat med consteval så är det läge att känna sig nöjd! Gott nytt!
Hoppas att det var givande Paul! Gott Nytt År!