TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24834 18
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
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 7, 2026Full Meeting C++ 2026 program released https://meetingcpp.com/mcpp/schedule/#2026 https://…
  2. Oct 7, 2026Qt moc now can handle basic C++ modules (Qt 6.12) https://codereview.qt-project.org/c/qt/q…
  3. Oct 7, 2026New to c++ Hello everybody,im new to cpp,and want to learn it,i have some knowledge with C…
  4. Oct 7, 2026Optimizing the Compressed Log Pipeline: https://github.com/Tencent/BqLog/blob/main/docs/Ar…
  5. Oct 7, 2026BqLog 2.6.0: a C++ logging library running on 30M+ devices daily, benchmarked against quil…
  6. Oct 7, 2026BqLog 2.6.0: a C++ logging library running on 30M+ devices daily, benchmarked against quil…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →