写了一个小代码,里面有一段是将int转换为bitset<16>,然后test第actPos位是否为1
一开始用
if((static_cast<std::bitset<16>>(wordIntVec[j])).test(actPos))
在vs2008中编译通过,但是用http://dsalgo.openjudge.cn平台的G++4.5编译,出现以下错误:
1479571.13137/Main.cc: In function ‘int main()’: 1479571.13137/Main.cc:34:38: error: ‘wordIntVec’ cannot appear in a constant-expression 1479571.13137/Main.cc:34:49: error: ‘j’ cannot appear in a constant-expression
最后将上面这一句改成
if(std::bitset<16>(wordIntVec[j]).test(actPos))
通过了
问题:
G++4.5不支持static_cast?
static_cast不是cpp标准里的东西么?