std::list.erase(itor)在Android和Win32之间存在差异
std::list.erase(itor) have differences between Android and Win32
如果我在for循环中使用iterator
,并且在迭代器的当前迭代中使用erase
,我发现Android
和WIN32
之间存在一些差异
std::list<StackData*>::iterator itor;
std::list<StackData*>::iterator firstDelItor = __mStack.begin();
for(itor = __mStack.begin(); itor != __mStack.end();)
{
firstDelItor = itor;
PRINT_LOG(LOG_TAG, "A itor[%p] firstDelItor[%p]", *itor, *firstDelItor);
itor = __mStack.erase(itor);
PRINT_LOG(LOG_TAG, "B itor[%p] firstDelItor[%p]", *itor, *firstDelItor);
...
}
Android:erase(itor)
之后,firstDelItor
的值不变。
23766-23766 D/TAG: A itor[0x9b979fe0] firstDelItor[0x9b979fe0]
23766-23766 D/TAG: B itor[0x9b8e9dbc] firstDelItor[0x9b979fe0]
并且在WIN32上:firstDelItor
的值变为0xdddddddd
。
TAG : A itor[0C6172D8] firstDelItor[0C6172D8]
Fatal at PRINT_LOG(LOG_TAG, "B itor[%p] firstDelItor[%p]", *itor, *firstDelItor); (itor = 0xcdcdcdcd, firstDelItor = 0xdddddddd)
因此,请解释在这种情况下Android
和WIN32
之间的区别。
"对已擦除元素的引用和迭代器无效。"http://en.cppreference.com/w/cpp/container/list/erase
相关文章:
- C++中std::resize(n)和std::shrink_to_fit之间的区别
- int(c) 和 c-'0' 之间的区别。C++
- Win32编译器选项和内存分配
- 在cuda线程之间共享大量常量数据
- 在c代码之间共享数据的最佳方式
- Mix_Init和Mix_OpenAudio SDL之间的区别是什么
- C++ 使用 assign 函数的字符串与直接使用 '=' 更改值的字符串之间的区别
- VSOMEIP-2个设备之间的通信(TCP/UDP)不工作
- std::atomic和std::condition_variable wait,notify_*方法之间的区别
- 大小相等但成员数量不同的结构之间的性能差异
- Electron应用程序和Win32本机桌面应用程序之间的进程间通信
- 在C Win32中的两个窗口之间切换
- 在 win32 中调用WM_PAINT之间保留绘制的工作区
- 如何使用C Win32 API计算两个日期之间的天数
- 使用Visual Studio 2010的win32和x64之间的生成时间差异很大
- 无法理解普通 c++ 与 vc++、win32 编程、mfc、win32 api、CLI 之间的关系
- 在 win32、c++ 中的 2 个进程之间共享相同的标准输出
- 在 Windows 服务和 Win32 应用程序C++之间使用 IPC
- 管理Win32应用程序和QWinMigrate之间的键盘事件
- std::list.erase(itor)在Android和Win32之间存在差异