Is this warning related to enum class size wrong?

前端 未结 2 1979
执念已碎
执念已碎 2021-01-19 02:55

Warning:

src/BoardRep.h:49:12: warning: ‘BoardRep::BoardRep::Row::::a’ 
is too small to hold all values of ‘enum class BoardRep::Piec         


        
2条回答
  •  滥情空心
    2021-01-19 03:34

    According to the C++ Standard

    8 For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type.

    So the values of your enumeration are in the range

    std::numeric_limits::min() - std::numeric_limits::max()
    

    Bit field a defined as

    Piece a:2;
    

    can not hold all values of the enumeration.

    If you would define an unscoped enumeration without a fixed underlying type then the range of its values would be

    0 - 2
    

提交回复
热议问题