Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
In the spirit of constexpr all the things, I thought if I could do advent of code completely at compile time. Right now, I am reworking the solutions I already have to be able to run completely constexpr. You can have a look at https://gitlab.com/n31415/compile_time_aoc/-/tree/trunk
Constexpr functions also make certain metaprogramming tricks a lot easier. Where before, you'd instanciate lots of templates to compute a value recursively, you can often just have a constexpr function compute the value iteratively. High-performance libraries rely a lot on such tricks to optimize code. E.g. the CTRE library is made up almost entirely of constexpr functions, and allows the libary to instanciate a state machine for parsing your regex at compile-time. This allows for significantly faster regex-matching at runtime. Take a look at this file to get an idea just how much can be done with constexpr functions.
Is C enough? https://github.com/keiichiw/constexpr-8cc
Related posts
- Regular Expression COmpiler - Compile a regex ahead of time to code
- What are thoughts on removing regular expression from the standard library?
- Verify all characters are same except a few
- Constexpr regex parser!
- Regex is comically slow. High performance alternatives? (Pattern matching for validation)