Transitive const sucks

Christopher Wright dhasenan at gmail.com
Tue Sep 11 13:36:12 PDT 2007


Steven Schveighoffer wrote:
> "Janice Caron" wrote
>> On 9/11/07, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>>> but what about instances where you want derived
>>> classes to be able to access the cache?
>> I can't think of a use-case for that.
> 
> The one that comes to mind is if you wanted to slightly modify the way a 
> cache was used.  The two options are: make the cache protected, and allow 
> derived classes to use it (in which case mutable is required), or 
> re-implement the cache in the slightly modified way in the derived class, in 
> which case you are carrying around 2 caches for no reason.

Provide a property to access the cache. It'll likely be inlined, so no 
performance hit.




More information about the Digitalmars-d mailing list