cannot cast

Namespace rswhite4 at googlemail.com
Thu May 3 01:00:42 PDT 2012


> If you want to restrict opCast, then use a template constraint, 
> constraining
> it to what you want to work with it. Also, casting away const 
> is generally a
> bad idea in D. Casting away const and mutating a variable is an 
> _extremely_
> bad idea. You _really_ shouldn't be doing it. So, the fact that 
> you _have_ a
> function which is specifically trying to cast away const is 
> almost certainly
> _not_ a good idea.
>
> http://stackoverflow.com/questions/4219600/logical-const-in-d
>
>
> - Jonathan M Davis

So, you mean that if i declared any parameter as const, it have 
to stay const all the time?
What would you do, if you need in a special case a mutable 
version or must change the object itself?
Because there is no "mutable" keyword in D you have to cast away 
the constness.



More information about the Digitalmars-d-learn mailing list