Daily Shaarli

All links of one day in a single page.

April 26, 2015

Non-constant constant-expressions in C++

Implementing f() to make the following snippet compile without the static_assert being fired looks impossible, doesn't it?

// <insert solution here>

int main () {
constexpr int a = f ();
constexpr int b = f ();

static_assert (a != b, "fail");
}