The below statement works in VS60
m_viSOFMarker = m_viEOFMarker = m_viReadIter = 0;
Now, in VS2008, we get a compilation error
c:\dev\src\nkt\commonsource\source\cmsgframebuffer.cpp(87) : 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
9.0\vc\include\vector(405): could be 'std::_Vector_iterator<_Ty,_Alloc>
&std::_Vector_iterator<_Ty,_Alloc>::operator =(const
std::_Vector_iterator<_Ty,_Alloc> &)'
1> with
1> [
1> _Ty=char,
1> _Alloc=std::allocator<char>
1> ]
1> while trying to match the argument list
'(CMsgFrameBuffer::TFrameBuffVIter, int)'
1>
We get the same for " ! " and "!=" operators
if( ! m_viSOFMarker ) m_viSOFMarker = m_vBuffer.begin();
1>c:\dev\src\nkt\commonsource\source\cmsgframebuffer.cpp(99) : error
C2675: unary '!' : 'CMsgFrameBuffer::TFrameBuffVIter' does not define
this operator or a conversion to a type acceptable to the predefined
operator
! m_viSOFMarker
1>c:\dev\src\nkt\commonsource\source\cmsgframebuffer.cpp(157) : error
C2678: binary '!=' : no operator found which takes a left-hand operand
of type 'CMsgFrameBuffer::TFrameBuffVIter' (or there is no acceptable
conversion)
1> c:\program files\microsoft
sdks\windows\v6.0a\include\guiddef.h(197): could be 'int operator
!=(const GUID &,const GUID &)'
1> c:\program files\microsoft visual studio
9.0\vc\include\vector(214): or 'bool
std::_Vector_const_iterator<_Ty,_Alloc>::operator !=(const
std::_Vector_const_iterator<_Ty,_Alloc> &) const'
1> with
1> [
1> _Ty=char,
1> _Alloc=std::allocator<char>
1> ]
1> while trying to match the argument list
'(CMsgFrameBuffer::TFrameBuffVIter, int)'
ANy reason why this is happening? Do we need to create operator!=,
operator= and operator! functions? I found something in MSDN that said
iterators have changed but I'm not following. I'm sure this is simple,
but I'm missing something. We're upgrading all source to VS2008, but
need it to still work in VS60 if need be. If need be, we'll do
conditional compiles.
Below is the class definition
#include <vector>
class CMsgFrameBuffer
{
typedef std::vector<char> TFrameBuffV;
typedef TFrameBuffV::iterator TFrameBuffVIter;
TFrameBuffV m_vBuffer; // the data buffer
TFrameBuffVIter m_viReadIter, // stores the next element
to read
m_viSOFMarker, // denotes the start of the frame
m_viEOFMarker; // denotes the end of the frame
...
...
}
This is happening because vector iterators are pointers in VC6, but not in VC8.
Your code was always wrong; it just happened to work in VC6.