I'd love for someone to add this to rebar[1] so that we can get a good sense of how well it does against other general purpose regex engines. It will be a little tricky to add (since the build step will require emitting a C++ program and compiling it), but it should be possible.
I know. I'm not really looking to compare it with C++'s standard library regex engine. (Although if someone wanted to do that work, I would welcome it into the benchmark.)
There are other engines written in C++ (in part or in whole) in rebar. And it is useful to compare it with engines not written in C++ too.
It's a good library but be careful as it can significantly increase compile times. I added a couple of reasonably long regular expressions to a c++ source file and it increased the compile time from near instant (below to 1 second) to 30 seconds. Might be wise to move these to dedicated source files so you don't pay this penalty each time you make changes.
I had great results with this back in the day. The template meta programming DSL you had to use was pretty horrifying but it was a triumph of what you could do with template metaprogramming (which was something discovered, not designed, in C++).
The first compile time regular expressions I saw that just used normal regular expressions was D's CTRE which produced an even faster "engine" than Boost Xpressive. This was thanks to D's compile time function evaluation reaching a point something like this was possible.
I just started using this CTRE for a regular expression whose performance had become problematic and I'm very impressed with it so far. It's pretty easy to surpass std::regex but not sacrificing usability was surprising. Build times haven't been affected too much either (for my use case).
One of the stated benefits is that the compiler optimizer can optimize the regex state machine that gets created, resulting in significantly faster match times at runtime. There are some benchmarks if you look up her cppcon talk about the library iirc.
Since people is posting other lang implementations... someone did it for zig too (probably less polished than this C++ lib) [0]. It is nice that the regexes can be used at compile time too [1].
1: I think the difference between C++ template language and Zig comptime is that Zig's comptime is almost equal as Zig's regular language, whereas the experience of programming C++ templates almost feels like learning a separate, equally complex language.
I've never used cl-ppcre myself, but its docs[1] claim that it provides compile-time regexes:
> CL-PPCRE uses compiler macros to pre-compile scanners at load time if possible. This happens if the compiler can determine that the regular expression (no matter if it's a string or an S-expression) is constant at compile time and is intended to save the time for creating scanners at execution time (probably creating the same scanner over and over in a loop).
I think this is more like caching the regex than creating it at compile time? Load time I think is basically runtime. I think lisp can be loaded and then rehydrated later, but I'm not sure how common that is.
Isn’t the issue with functions like this that they are not guaranteed to be the same on all hardware? So making it constexpr could break programs or cause the constexpr evaluated result to differ from the runtime result even for the same inputs
[1]: https://github.com/BurntSushi/rebar