我的问题是我的代码的某些部分在发布模式下运行没有问题,但在调试模式下出现错误。
设置:C++ 17 - Visual Studio 2019
为了显示差异,我写了一个小测试代码:
int main()
{
//Vector containing 20 lists with length of 10 each. Every Element = 10
std::vector<std::list<int>> test(20, std::list<int>(10,10));
std::cout << test[6].front() << std::endl; //test if initialization worked
std::list<int>::iterator test_iter;
for (test_iter = test[6].begin(); test_iter != test[6].end(); test_iter++)
{
std::cout << *test_iter << std::endl;
test[6].erase(test_iter);
}
}
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么两种模式之间存在差异以及我如何调整它,因此调试模式也能正常工作?
提前感谢您的帮助!
最好的问候大卫