Assertion failure

My program has no error and when I run it with VS2008 it gives:
"
Program...........
File:d:\program files (x86)\microsoft visual studio 9.0\vc\include\vector
Line:163

Expression:("_Myptr + _Off <= ((_Myvec *)(this->_Getmycont()))->_Mylast && _Myptr + _Off >= ((_Myvec *)(this->_Getmycont()))->_Myfirst", 0)
"

The segment mentioned of the file is
"
_Myt& operator+=(difference_type _Off)
{ // increment by integer
_SCL_SECURE_VALIDATE(this->_Has_container());
_SCL_SECURE_VALIDATE_RANGE(
_Myptr + _Off <= ((_Myvec *)(this->_Getmycont()))->_Mylast &&
_Myptr + _Off >= ((_Myvec *)(this->_Getmycont()))->_Myfirst);
_Myptr += _Off;
return (*this);
}
"

When I run it with VS2010 it gives:
"
File: c:\program files (x86)\microsoft visual studio 10.0\vc\vector
Line:157

Expression: vector iterator + offset out of range
"

I would really appreciate it if any of you can solve me problem!
You appear to be using an iterator for your vector, and it's attampting to go past the end of the range of the vector.

I would suggest you iterate through your vector thus:

1
2
3
4
5
6
7
8
vector<int> v;

// fill vector

for (auto p = v.begin(); p != v.end(); ++p)
{
   // do stuff with *p
}
Thank you for your advice. Woooo I am using an iterator for my vector and I was using while structure. I tried but your suggestion didn't work out.
Could you post the code causing the error? And by that I mean your code, not the library code where it is failing; step up the call stack.
would you please show us your code?
I re-installed my VS and the problem has been solved~^.^ Seems that it was the problem of VS~
Topic archived. No new replies allowed.