E
EvilOldGit
const Thing &operator++(int)
{
Thing temp = *this;
operator++();
return temp;
}
Is this code robust ?
I get a compiler warning about returning a reference to a a local,
which I guess is because the compiler doesn't tell the difference
between this overload any any other function.
Thing x,y;
x = y++;
Is OK because it's thrown away, and it's a copy of non-incremented y
that gets assigned.
y++ = x;
Does things to my head, but can't happen because I'm returning a
const.
const_casting<> doesn't
But could a (creatively stupid) user of my code do some harm ?
{
Thing temp = *this;
operator++();
return temp;
}
Is this code robust ?
I get a compiler warning about returning a reference to a a local,
which I guess is because the compiler doesn't tell the difference
between this overload any any other function.
Thing x,y;
x = y++;
Is OK because it's thrown away, and it's a copy of non-incremented y
that gets assigned.
y++ = x;
Does things to my head, but can't happen because I'm returning a
const.
const_casting<> doesn't
But could a (creatively stupid) user of my code do some harm ?