Logical const

Simen kjaeraas simen.kjaras at gmail.com
Sun Nov 28 07:57:19 PST 2010


Jonathan M Davis <jmdavisProg at gmx.com> wrote:

> So, _I_ am certainly not aware of a good solution, but if you play  
> games, you
> should be able to get _something_ working. Overall though, I think that  
> the
> lesson is that you should really be making const functions truly const  
> and not
> try and deal with logical const at all.

Highly unsafe, but works in the cases you'd expect. Use with extreme
caution:


import std.traits;
@system
ref Unqual!T unqualified( T )( ref const T t ) {
     Unqual!(T)* p = cast(Unqual!(T)*)&t;
     return *p;
}

-- 
Simen


More information about the Digitalmars-d mailing list