mardi 27 septembre 2016

constexpr function must have one argument value?

According to this, a function declared with constexpr must satisfy a few requirements, one of which is as follows:

there exists at least one argument value such that an invocation of the function could be an evaluated subexpression of a core constant expression

constexpr function can have no arguments:

constexpr int Bar( /* empty */ ) { return 0xFF; }
constexpr int value = Bar(); // Valid expression

constexpr function that is invoked as a sub-routine can not determine the whole expression to be core constant expression either.

So what does it mean by one argument value must exist?

Aucun commentaire:

Enregistrer un commentaire