Subject: Re: Decouple constness for inherited interfaces
From: Lior Lahav (lahavlior_at_[hidden])
Date: 2019-09-21 18:02:37
> the cases where the interface explicitly wants that any and all
derived classes should have no side-effects
It is currently possible in CPP. Declaring a base class interface method as
const ensures that a derived overridden method won't have side effects,
however that is in contradiction to my argument, claiming that it is not
necessary nor necessarily correct.
Occasionally that leads to reluctantly declare variables in derived classes
as mutables or use const cast.
Backward compatibility should be preserved, compiling an existing code
should result in identical results having this new 'mutable' keyword
On Sat, 21 Sep 2019 at 22:52, Thiago Macieira via Std-Discussion <
> On Friday, 20 September 2019 20:50:56 PDT Lior Lahav via Std-Discussion
> > It would be logical that a pure abstract class const correctness would be
> > decoupled from an implementation and should not dictate whether derived
> > class should have side effects.
> Except for the cases where the interface explicitly wants that any and all
> derived classes should have no side-effects. How should one write such a
> declaration (in the base class) that guarantees this contract?
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Software Architect - Intel System Software Products
> Std-Discussion mailing list
STD-DISCUSSION list run by herb.sutter at gmail.com
Older Archives on Google Groups