Tuesday, October 11, 2022

Digest for comp.lang.c++@googlegroups.com - 1 update in 1 topic

Richard Damon <Richard@Damon-Family.org>: Oct 10 08:47PM -0400

On 10/10/22 8:08 AM, Juha Nieminen wrote:
> is to make it non-const and then in the derived class create a const
> version that calls the non-const one using a const_cast. It might be
> a bit ugly, but it's the best we got."
 
Which is sort of what I described, except I would probably define in the
derived class the CONST version, and make the non-const version forward
to it, since that is always well defined.
 
If the const version is called on an actual const object, and then it
const-casts to the non-const version, and that ends up actually not
being actually const, then you have invoked undefined behavior.
 
 
As I was pointing out, if you end up in this situation, your really need
to evaluate why you got there, as something seems off.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: