Implementing a Compile-Time Sudoku Solver in Modern C++ (C++20/23
I’ve been experimenting with **constexpr** and template metaprogramming in C++20/23, and I thought it would be fun to implement a **Sudoku solver entirely at compile-time**.
* The idea is to encode the Sudoku grid as `constexpr` arrays.
* All solving logic happens using **compile-time recursion and constraints**, leveraging concepts and `consteval` functions.
* The compiler does all the heavy lifting, so when the program runs, the solution is already baked in.
I’d love feedback on:
1. How to make the solver more **efficient for larger grids** at compile-time.
2. Best practices for **readable compile-time recursion** without hitting template depth limits.
3. How to **debug constexpr code** effectively in real-world projects.
I can share a **minimal working example** if people are interested.
Has anyone else tried doing heavy algorithmic work entirely at compile-time?
https://redd.it/1rougbu
@r_cpp
Post #24834
18