I don't know if it is meaningful to define a variable with constexpr in a function.
void func() { static const int i = 1; }
void func2() { constexpr const int i = 1; }
static const
in a function would be initialized on the first function call, how about constexpr
in a function? I know that constexpr
specifies that the object should be available during compilation. So does it mean that the variable i
in the func2
would be evaluated at compile time whereas the i
in the func
wouldn't?
Aucun commentaire:
Enregistrer un commentaire