constexpr uint32_t BitPositionToMask(int i,int Size){
static_assert(i < Size,"bit position out of range");
return 1 << i;
}
this generates:
error: non-constant condition for static assertion
on GCC 4.6.2 Am I not getting something or is this a GCC bug?
A constexpr
function can also be invoked with arguments evaluated at run-time (in that case, it just gets executed just like any regular function). See, for instance, this live example.
A static_assert()
, on the other hand, strictly requires its condition to be a constant expression that can be evaluated at compile time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With