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?
Update:
thank you Andy for being my nerd guardian angel again. Since I have the values at compile time anway I just made it a template and it works as intended.
template<int i,int Size>
constexpr uint32_t BitPositionToMask(){
static_assert(i < Size,"bit position out of range");
return 1 << i;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…