hanickadot/compile-time-regular-expressions
View on GitHub ↗ ★ 3,874 C++
Compile Time Regular Expression in C++
15 mentions on Hacker News by 14 people: 2 stories, 13 comments · first 2018-10-14 · latest 2026-01-14
20082026
-
Other examples are CTRE ( https://github.com/hanickadot/compile-time-regular-expressio... ) and format string compilation ( https://fmt.dev/12.0/api/#compile-api ). The closest C counterpart is re2c which also requires external tooling.
comment by vitaut · 2026-01-14 · in Is Rust faster than C? -
https://github.com/hanickadot/compile-time-regular-expressio...
comment by SuperV1234 · 2025-11-01 · in The Impossible Optimization, and the Metaprogramming to Achieve It -
The problem can occur in general if there is a greedy match within the regex: https://github.com/hanickadot/compile-time-regular-expressio... Although it looks like that this got fixed for simple patterns.
comment by leni536 · 2025-04-19 · in Less Slow C++ -
Hana Dusikova did this in C++ several years ago, with her CTRE library. https://github.com/hanickadot/compile-time-regular-expressio... Of course, it has all the usual tradeoffs of compile-time template programming.
comment by jonstewart · 2024-10-20 · in Implementing Regular Expressions in TypeScript Types (Badly) -
entirely. Good alternatives are CTRE ( https://github.com/hanickadot/compile-time-regular-expressio... ) which parses the regex and instantiates the automaton entirely at compile-time, or Google's re2 ( https://github.com/google/re2 ) if…
comment by jcelerier · 2024-09-05 · in Giving C++ std:regex a C makeover -
I don't want to start a language war, given that I like both languages anyway, you should have a look at https://github.com/hanickadot/compile-time-regular-expressio... However even counting with upcoming C++23 features, Lisp is much more…
comment by pjmlp · 2022-04-22 · in Common Lisp Resources -
I agree with your list. However, I don't find the first library you referenced readable (i.e. https://github.com/hanickadot/compile-time-regular-expressio... ), and I am a C++ user since the nineties.
comment by jeffreygoesto · 2020-10-28 · in Ask HN: Good C++ code bases to read? -
Here are a couple of expertly-written C++17/C++20 repositories: https://github.com/hanickadot/compile-time-regular-expressio... https://github.com/nlohmann/json If you've not written C++ code before, it can take a while to catch up with…
comment by artagnon · 2020-10-28 · in Ask HN: Good C++ code bases to read? -
One use case of something similar is generating a regular expression matcher at compile time for example. This is what the C++ library https://github.com/hanickadot/compile-time-regular-expressio... does. There are a lot of uses of…
comment by nikki93 · 2020-09-28 · in Show HN: A SQL database implemented purely in TypeScript type annotations -
> Passing strings into a templates ... wouldn't work in C++ ... https://www.youtube.com/watch?v=QM3W36COnE4 Here's an example of parsing regular expressions in C++ at compile time. Code here: https://github.com/hanickadot/compile-time-regul…
comment by nikki93 · 2020-09-07 · in C++20 has been approved -
> I really don't get this argument. If you don't need pedal-to-the-metal performance then why are you using C++ in the first place? (Unless, of course, your answer is "legacy code".) There is many other things that pure compute-bound CPU…
comment by adev_ · 2020-04-27 · in Comparison of C++17, Go, and Java for a next-generation sequencing tool -
constexpr evaluation results are needed in the frontend long before LLVM IR ever comes into the picture. Also, people have done interesting things in constexpr that currently suffer from slow compile times:…
comment by bigcheesegs · 2019-07-03 · in ConstExprPreter – Clang Constexpr Interpreter -
C++ now has constexpr, so that pro is now shared by both C++ and D, somewhat (ignoring templates, D is still more versatile). That being said, C++ template metaprogramming can be pretty elegant[1] (there was a video where she describes the…
comment by zamalek · 2018-10-14 · in Why Zig When There Is Already CPP, D, and Rust? (2017)