A
Alexander Stippler
Hello,
I wonder if and in what cases casting const away by a const_cast can be
dangerous. In one place the only way I can imagine to realize a pretty
nice feature is casting away const. Now I wonder if this is dangerous. I
have something like that:
const Object &
Object::dummy(const AType &a) const
{
Object &refThis = const_cast<Object &>(*this);
AType &refA = const_cast<AType &>(rhs);
refThis.member = a.member();
...
}
Are there situations, where these constructs are dangerous?
I know, this code is ugly. But the realized feature is worth it.
regards,
Alex
I wonder if and in what cases casting const away by a const_cast can be
dangerous. In one place the only way I can imagine to realize a pretty
nice feature is casting away const. Now I wonder if this is dangerous. I
have something like that:
const Object &
Object::dummy(const AType &a) const
{
Object &refThis = const_cast<Object &>(*this);
AType &refA = const_cast<AType &>(rhs);
refThis.member = a.member();
...
}
Are there situations, where these constructs are dangerous?
I know, this code is ugly. But the realized feature is worth it.
regards,
Alex