|
QVector::isEmpty这个巨坑!!!
superlover 是不是多线程环境?没有加锁是有可能出现这种情况的。倒没有用到多线程。是一个计算器功能的实现,里面的逻辑分支太多了,出现了逻辑错误。如果是多线程,估计更加难以发现了。 |
|
|
|
QVector::isEmpty这个巨坑!!!
// 实验环境为32位 vector<int*> vec; std::cout << (vec.empty()) << std::endl; // 输出 1 vec.pop_back(); std::cout << (vec.empty()) << std::endl; // 输出 0, 其实没有元素的 std::cout << (vec.size()) << std::endl; // 输出 4294967295 std::cout << (int)vec.size() << std::endl; // 输出 -1
最后于 2024-3-22 08:47
被_THINCT编辑
,原因:
|
|
|
|
QVector::isEmpty这个巨坑!!!
值得怀疑 是空也进不到循环里啊, 怎么会调用pop?代码前面有pop_back导致了QVector的size为负数,而isEmpty的实现是size == 0. |
|
QVector::isEmpty这个巨坑!!!
contain_of 不太清楚Qt中QVector类是怎么定义的 但在std::vector里 空容器上调用pop_back导致未定义行为 如果容器为空 begin() == end() 为了程序的通用性 迭代器比较建 ...我没有试过std::vector,使用QVector为空的时候,继续pop_back会使其size一直减小,变成负数,导致end在begin前面。 |
|
|
|
|
|
|
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值