For example:
constexpr int g() { return 30; }
constexpr int f()
{
// Can we always omit const?
/* const */ int x = g();
/* const */ int y = 10;
return x + y;
}
Is there any point to ever declare local variables in a constexpr
function with const
?
Aren't constexpr
functions with const
local variables equivalent to those with no const
? In other words, does constexpr
on a function imply const
on its local variables?
Because if so, the version without const
would look more attractive for being slightly cleaner.
Aucun commentaire:
Enregistrer un commentaire