Neat hack! One minor improvement suggestion: if you seed the RNG with `__DATE__` (or a hash of that string), then you can replicate the one-puzzle-a-day experience with no need for an externally-supplied seed variable.
Good point! I wanted to be able to modify SEED in order to test that everything was fine with multiple words, using __DATE__ didn't come to mind :)
#ifndef SEED
#define SEED __DATE__
#endif
Wondering what happens if you allocate a chunk of uninitialized memory inside a constexpr? Could this be used for a quick constexpr RNG seed?
A very neat thing of constexpr is that it does not have undefined behaviour ; any thing that would cause UB at run-time is flagged as a compile error. Every variable must be fully initialized.
You simply can't. The constexpr environment won't let you have uninitialized variables/memory anywhere. It won't let you access dangling/out-of-bounds pointers either, overflow two-complement types, etc.
Accessing uninitialized objects is undefined behaviour, which traps in the constexpr context.
If you are wondering how constexpr works in the new C++20 please check this excellent article and corresponding HN discussions: