• 【cpp】G++中不支持static_cast?


    写了一个小代码,里面有一段是将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标准里的东西么?

  • 相关阅读:
    【程序25】
    【程序24】
    【程序23】
    【程序22】
    【程序21】
    【程序20】
    【程序19】
    【程序18】
    string用法总结
    快速排序
  • 原文地址:https://www.cnblogs.com/chenhuanfa/p/3331242.html
Copyright © 2020-2023  润新知