klic2rohit
February 1st, 2010, 04:24 AM
Hi,
Currently I am working in visual Studio 2008. Previously I was working in VS 2003 but I migrated the code VS2008.
I am getting below error in VS 2008 which was NOT in vS2003.
Error: _DEBUG_ERROR("vector iterators incompatible");
When i searched on the internet I found that it is due to strict type checking of vs2008.
Below is code snippet where I am getting run time error
bool CardCol::Contains(const TAMCardPtr pCard){ //collection class method
bool contains=containedincards_if(begin(),end(),bind2nd_ref(mem_fun(&CardCol::IsIdentical),pCard));
return contains;
}
template<class _InIt, class _Fn1> inline
bool containedincards_if(_InIt _First, _InIt _Last, _Fn1 _Func) {
return _Last!=findincards_if(_First,_Last,_Func); <-- error [("vector iterators incompatible")] while != comparsion
}
template<class _InIt, class _Fn1> inline
_InIt findincards_if(_InIt _First, _InIt _Last, _Fn1 _Func) {
for (; _First != _Last; ++_First){
if (_Func(*_First))
break;
if((*_First)->HasSlaveCards()){
_InIt itSlave;
for (itSlave=(*_First)->GetSlaveCards()->begin();itSlave!=(*_First)->GetSlaveCards()->end();++itSlave){
if (_Func(*itSlave))
break;
}
if (itSlave!=(*_First)->GetSlaveCards()->end())
return itSlave;
}
}
return _First;
}
Here I guess the failure is due to comparison of iteraotrs two different vectors of same type.
Currently I am working in visual Studio 2008. Previously I was working in VS 2003 but I migrated the code VS2008.
I am getting below error in VS 2008 which was NOT in vS2003.
Error: _DEBUG_ERROR("vector iterators incompatible");
When i searched on the internet I found that it is due to strict type checking of vs2008.
Below is code snippet where I am getting run time error
bool CardCol::Contains(const TAMCardPtr pCard){ //collection class method
bool contains=containedincards_if(begin(),end(),bind2nd_ref(mem_fun(&CardCol::IsIdentical),pCard));
return contains;
}
template<class _InIt, class _Fn1> inline
bool containedincards_if(_InIt _First, _InIt _Last, _Fn1 _Func) {
return _Last!=findincards_if(_First,_Last,_Func); <-- error [("vector iterators incompatible")] while != comparsion
}
template<class _InIt, class _Fn1> inline
_InIt findincards_if(_InIt _First, _InIt _Last, _Fn1 _Func) {
for (; _First != _Last; ++_First){
if (_Func(*_First))
break;
if((*_First)->HasSlaveCards()){
_InIt itSlave;
for (itSlave=(*_First)->GetSlaveCards()->begin();itSlave!=(*_First)->GetSlaveCards()->end();++itSlave){
if (_Func(*itSlave))
break;
}
if (itSlave!=(*_First)->GetSlaveCards()->end())
return itSlave;
}
}
return _First;
}
Here I guess the failure is due to comparison of iteraotrs two different vectors of same type.