Non-constant constant-expressions in C++ なんと、C++のconstexpr関数を呼び出すたびに戻り値を変える方法があるという。つまり、以下のstatic_assertが引っかかるコードだ。 int main () { constexpr int a = f (); constexpr int b = f (); static_assert (a != b, "fail"); } なんと、constexpr関数は状態を保持できる計算能力を備えているというのだ。 fはconstexpr関数である。 読んでみたところ、要するにこうだ。 noexcept演算子はオペランドが定数式かどうかを判別するのに使える。 // exprが定数式であればtrue constexpr bool b = noexcept( expr ) ; 未定義の関数は定数式ではない。

