I have this code:
const float foo = 5.0F;
static_assert(foo > 0.0F, "foo must be greater than 0.");
But in visual-studio-2010 I get the error:
error C2057: expected constant expression
I'm actually doing this correctly and visual-studio-2010 just hasn't properly implemented static_assert
, right? In visual-studio-2017 it works as intended.
There has been some commentary of the differences between const
and constexpr
. I understand this difference, however many compilers support this use of static_assert
so I'll ask again, is this legal code or not? I'm not as concerned about which compiler supports it, I'm concerned about whether it's defined under the C++ standard.