向量迭代器+偏移超出范围 [英] Vector iterator + offset out of range

查看:93
本文介绍了向量迭代器+偏移超出范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了以下问题:每当我想从向量中擦除时,都会收到一条消息向量迭代器+偏移量超出范围"

I'm suffering following issue: every time I want to erase from my vector I get a message "Vector iterator + offset out of range"

//LinearRWA.h

// LinearRWA.h

#include< vector>

#include <vector>

std :: vector< double> m_probabilities;

std::vector<double> m_probabilities;

 

//  LinearRWA.cpp

// LinearRWA.cpp

#include"LinearRWA.h"

#include "LinearRWA.h"

void LinearRWA :: removeLinTransform(unsigned short int index){

void LinearRWA::removeLinTransform(unsigned short int index) {

  ...

m_probabilities.erase(m_probabilities.begin()+ index);  //< --- here

m_probabilities.erase(m_probabilities.begin() + index); // <--- here

. ..

}

 

调试器告诉我,m_probabilities具有3个(正确的)成员,然后尝试擦除其中的一个.index== 0.

Debugger tells me that m_probabilities has 3 (correct) members before trying to erase one. index == 0.

我正在从C#项目调用的C ++ dll中使用此代码.

I'm using this code in a C++ dll called from a C# project.

到目前为止,还没有出现过此问题,最近也没有更改任何代码.只是突然发生了.我正在做的最后一件事是对象析构函数.我完全不知道为什么它现在不起作用了.

Haven't had this problem until now, haven't changed any of the code post recently. It just suddenly happend. Last thing I was working on were the object destructors. I have absolutely no idea why it doesn't work now although it did.

很高兴为您提供任何帮助.谢谢.

I'm glad for any help you can provide. Thanks.

推荐答案

哦-调试器告诉我m_probabilities.begin()模棱两可,无法评估.
Oh - and debugger tells me m_probabilities.begin() is ambiguous and can't be evaluated.


这篇关于向量迭代器+偏移超出范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆