std::vector<std::string>::iterator it;
it = NULL;
do
{
if(it == NULL)
it = init.begin();
else
++it;
if(it == init.end())
return 1;
}
while(it->empty());
The above piece of code works fine with VS2003, but when it is migrated to VS2010, it is giving compilation error saying
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
1> c:\program files\microsoft visual studio 10.0\vc\include\vector(388): could be 'std::_Vector_iterator<_Myvec> &std::_Vector_iterator<_Myvec>::operator =(const std::_Vector_iterator<_Myvec> &)'
1> with
1> [
1> _Myvec=std::_Vector_val<std::string,std::allocator<std::string>>
1> ]
1> while trying to match the argument list '(std::_Vector_iterator<_Myvec>, int)'
1> with
1> [
1> _Myvec=std::_Vector_val<std::string,std::allocator<std::string>>
1> ]
1>d:\vs2010_ws\acct ford 6.2.4 source code\acct_ford_ws\vector\src\driver\cancardxl.cpp(81): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::_Vector_iterator<_Myvec>' (or there is no acceptable conversion)
1> with
1> [
1> _Myvec=std::_Vector_val<std::string,std::allocator<std::string>>
1> ]
You were assuming that a vector iterator could be initialized and assigned from an int (or some form of pointer?). That’s not the case.
You can transform your loop to something like: