我在迭代集合时遇到段错误。
堆栈跟踪指向:
0x000000081193ccc5 in std::_Rb_tree_increment (__x=0x1) at /libstdc++/src/tree.cc:68
0x0000000806c3107e in std::_Rb_tree_const_iterator<test *>::operator++ at stl_tree.h:266
但我没有得到更多信息,但崩溃的最后一行如下所示。
迭代器遍历一个集合。
typedef std::set<test*,test_less> test_set_t;
test_set_t& set(bt->getSet()); // getSet() will return reference to the class bt member variable set
test_set_t::iterator pos = set.begin();
test empty(val);
test* last_ptr = ∅
for (; pos != set.end(); last_ptr = *pos++) { // gdb shows this as last line
我看不到这个问题。提前致谢。
最佳答案
很可能该集合为空,或者您删除了 pos
在迭代时指向的项目。
关于c++ - 来自 std::_Rb_tree_increment (__x=0x1) 的段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9034749/