K
kwikius
Is the marked section in main so-called "undefined behaviour".
struct value_type{
value_type (): v(0){}
value_type & operator = ( value_type const & in)
{
v = in.v;
return *this;
}
int v;
};
inline
value_type operator++(value_type & x,int)
{
value_type t = x;
++x.v;
return t;
}
int main()
{
value_type x;
//####################
x = x++; // undefined behaviour ??
//###############
x = (x++);
(x = x)++;
}
IMO it aint where x is a UDT with overloaded post operator ++.
But maybe I'm wrong?...
regards
Andy Little
struct value_type{
value_type (): v(0){}
value_type & operator = ( value_type const & in)
{
v = in.v;
return *this;
}
int v;
};
inline
value_type operator++(value_type & x,int)
{
value_type t = x;
++x.v;
return t;
}
int main()
{
value_type x;
//####################
x = x++; // undefined behaviour ??
//###############
x = (x++);
(x = x)++;
}
IMO it aint where x is a UDT with overloaded post operator ++.
But maybe I'm wrong?...
regards
Andy Little