C++ deque迭代器在调试模式下不可取消引用错误
我需要你的帮助。 我正在编写一个C++应用程序,它在我的代码中使用了队列STL容器。 在访问该队列的front()元素时,我遇到了一个“deque iterator not Dereferenceable”错误。此特定错误仅在调试模式下出现 代码如下C++ deque迭代器在调试模式下不可取消引用错误,c++,iterator,dereference,deque,C++,Iterator,Dereference,Deque,我需要你的帮助。 我正在编写一个C++应用程序,它在我的代码中使用了队列STL容器。 在访问该队列的front()元素时,我遇到了一个“deque iterator not Dereferenceable”错误。此特定错误仅在调试模式下出现 代码如下 由于我正在从队列中弹出数据,因此在访问队列的front()之前,我将检查队列是否为空。但还是会出错 当我彻底调试时,错误出现在Visual Studio的deque文件中: reference operator*() const
由于我正在从队列中弹出数据,因此在访问队列的front()之前,我将检查队列是否为空。但还是会出错 当我彻底调试时,错误出现在Visual Studio的deque文件中:
reference operator*() const
{ // return designated object
const auto _Mycont = static_cast<const _Mydeque *>(this->_Getcont());
#if _ITERATOR_DEBUG_LEVEL == 2
if (_Mycont == 0
|| this->_Myoff < _Mycont->_Myoff
|| _Mycont->_Myoff + _Mycont->_Mysize <= this->_Myoff)
{ // report error
_DEBUG_ERROR("deque iterator not dereferencable");
}
引用运算符*()常量
{//返回指定对象
const auto_Mycont=static_cast(this->_Getcont());
#如果_迭代器_调试_级别==2
如果(_Mycont==0
||这个->\u Myoff<\u Mycont->\u Myoff
||_Mycont->_Myoff+_Mycont->_Mysize\u Myoff)
{//报告错误
_调试_错误(“deque迭代器不可解引用”);
}
这里,
\u Mycont
正在获取null/zero,这是预先引发此异常的。有人能告诉我为什么我会获得此错误吗?似乎您正在对不同的对象调用empty
和front
:TimeSeriesApp::Instance::TimeSeriesAppInstance->haraldMsgDb
vsApp::Instance->haraldMsgDb
>。但是如果不知道这些标识符是如何声明的,就不可能确定。我不好,empty也只在App::Instance->haraldMsgDb上调用。这只是输入错误。关于声明,它在头文件中定义为-std::queue haraldMsgDbIt,似乎您正在调用di上的empty
和front
不同的对象:TimeSeriesApp::TimeSeriesAppInstance->haraldMsgDb
vsApp::Instance->haraldMsgDb
。但是如果不知道这些标识符是如何声明的,就无法确定。sry my bad,empty也仅在App::Instance->haraldMsgDb上调用。这只是打字错误。关于声明,它是定义的在头文件中作为-std::queue haraldMsgDb
data += App::Instance->haraldMsgDb.front();
reference operator*() const
{ // return designated object
const auto _Mycont = static_cast<const _Mydeque *>(this->_Getcont());
#if _ITERATOR_DEBUG_LEVEL == 2
if (_Mycont == 0
|| this->_Myoff < _Mycont->_Myoff
|| _Mycont->_Myoff + _Mycont->_Mysize <= this->_Myoff)
{ // report error
_DEBUG_ERROR("deque iterator not dereferencable");
}