没有合适的资源?快使用搜索试试~ 我知道了~
Set集合BUG
需积分: 10 0 下载量 82 浏览量
2018-06-14
13:50:38
上传
评论
收藏 3KB TXT 举报
温馨提示
试读
2页
修改头文件sysset.h ,使C++builder中Set集合类ToInt出错的问题解决
资源推荐
资源详情
资源评论
//sysset.h 修改头文件 参考帖子:https://blog.csdn.net/maozefa/article/details/36498943
int __fastcall ToInt(void) const //修改后的
{
#pragma option push -w-inl
int Result = 0;
for (int i = sizeof(SetBaseT::Data)-1; i >= 0; i--)
{
Result |= SetBaseT::Data[i];
if (i) //如果i = 0时不再作移位
Result <<= (sizeof(unsigned char) * 8);
}
return Result;
#pragma option pop
}
// int __fastcall ToInt(void) const //201804.28 Decn 系统原来的源码,类集合超过15时会计算出错误的结果
// { 例如enum TTest{tt0,tt1,tt2,tt3,tt4,tt5,tt6,tt7,tt8,tt9,tt10,tt11,tt12,tt13,tt14,tt15,tt16,tt17,tt18,tt19,tt20,tt21,tt22,tt23,tt24,tt25,tt26,tt27,tt28,tt29,tt30,tt31,tt32};
// #pragma option push -w-inl typedef Set<TTest,tt0,tt16> TTests;
// int Result = 0; sizeof(TTest) = 4;
// for (int i = sizeof(SetBaseT::Data)-1; i >= 0; i--) 当:TTest t16 = TTest()<<tt16;
// { t16的内存存储为
// Result |= SetBaseT::Data[i]; 0000 0000|0000 0001|0000 0000|0000 0000
// Result <<= (i * sizeof(unsigned char) * 8); 3 2 1 0
// } 取数据时会把3 byte的数据左移 3+2+1次,但这是错误的,应该是3次
// return Result; 2 2+1 2
// #pragma option pop 1 1 1
// } 0 0 0
// int __fastcall GetByte(int index) const 2018.04.28 Decn 测试代码,用来取得类集合中的第index位转化为int后的值,超过范围将取得0
int __fastcall ToInt(void) const //修改后的
{
#pragma option push -w-inl
int Result = 0;
for (int i = sizeof(SetBaseT::Data)-1; i >= 0; i--)
{
Result |= SetBaseT::Data[i];
if (i) //如果i = 0时不再作移位
Result <<= (sizeof(unsigned char) * 8);
}
return Result;
#pragma option pop
}
// int __fastcall ToInt(void) const //201804.28 Decn 系统原来的源码,类集合超过15时会计算出错误的结果
// { 例如enum TTest{tt0,tt1,tt2,tt3,tt4,tt5,tt6,tt7,tt8,tt9,tt10,tt11,tt12,tt13,tt14,tt15,tt16,tt17,tt18,tt19,tt20,tt21,tt22,tt23,tt24,tt25,tt26,tt27,tt28,tt29,tt30,tt31,tt32};
// #pragma option push -w-inl typedef Set<TTest,tt0,tt16> TTests;
// int Result = 0; sizeof(TTest) = 4;
// for (int i = sizeof(SetBaseT::Data)-1; i >= 0; i--) 当:TTest t16 = TTest()<<tt16;
// { t16的内存存储为
// Result |= SetBaseT::Data[i]; 0000 0000|0000 0001|0000 0000|0000 0000
// Result <<= (i * sizeof(unsigned char) * 8); 3 2 1 0
// } 取数据时会把3 byte的数据左移 3+2+1次,但这是错误的,应该是3次
// return Result; 2 2+1 2
// #pragma option pop 1 1 1
// } 0 0 0
// int __fastcall GetByte(int index) const 2018.04.28 Decn 测试代码,用来取得类集合中的第index位转化为int后的值,超过范围将取得0
资源评论
qq_35130856
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功