Yet Another Const Proposal

Janice Caron caron800 at googlemail.com
Sat Dec 8 04:00:00 PST 2007


On 12/7/07, Sönke Ludwig <ludwig at informatik_dot_uni-luebeck.de> wrote:
> This in turn makes the
> TailInvariant!()-solution impossible without severly hacking around the type
> system.

Yes, I had it in my head that TailConst! and TailInvariant! would be
impossible without casting away const somewhere along the line. I got
temporarily distracted when Walter said it could be done without
casting away const by wrapping the class in a struct. I should have
spotted then that const-correctness was being violated, but I wasn't
paying enough attention.

I don't necessarily think this is a problem though (although
overwriting const data obviously /is/), because TailConst! and
TailInvariant! would be library-supplied templates, written by people
who completely understood what was happening "under the hood", and one
would assume that writers such as Walter or Andrei could write them in
a "safe" way. (I'm sure I could have a bash myself, for that matter).

But yeah - the assignment of structs which contain const or invariant
members, is a violation of const correctness, and I believe it needs
to be fixed.




More information about the Digitalmars-d mailing list