Answer the question
In order to leave comments, you need to log in
Generating a random string at compile time?
I figured out for myself a new type of constexpr functions, which is performed at the compilation stage, but there is such a thing that constexpr type functions do not execute functions in their body that have a non-constexpr type.
That is, I can’t call either MessageBox or rand from a function with type constexpr.
On the Internet they write that you need to get a single image of a pseudo-random number based on macros (__TIME__, __TIMESTAMP__, etc.). Is this the case, or can this issue be resolved?
Answer the question
In order to leave comments, you need to log in
1. The current timestamp is often taken to initialize a standard C/C++ random number generator.
An example can be
found here: https://en.cppreference.com/w/cpp/numeric/random/srand
3. You don't need to basically call MessageBox and any similar functions at the program compilation stage.
constexpr functions are executed by the compiler, so they are quite severely restricted. When the program is executed, instead of calling the constexpr function, there is already a value previously calculated by the compiler.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question