mardi 27 août 2019

const ok, but not constexpr?

With a constexpr-specified function foo_constexpr I have code such as shown below:

const auto x = foo_constexpr(y);
static_assert(x==0);

Under which circumstances could the code then fail to compile, when the declaration of x is changed to constexpr? (After all, x must already be a constant expression for use in the static_assert.) That is:

constexpr auto x = foo_constexpr(y);
static_assert(x==0);

Aucun commentaire:

Enregistrer un commentaire