Hacker News new | ask | show | jobs
by arijun 1006 days ago
At the risk of sounding like an idiot, what is the benefit of being able to match at compile time?
2 comments

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.

Edit: here is her talk, at 39 minutes she shares the benchmarks. https://m.youtube.com/watch?v=QM3W36COnE4

It's not necessarily match at compile time, it's compile the regex at compile time to eliminate all superfluous runtime costs.