shouldn't const cast always be allowed (even if shunned)

Dan dbdavidson at yahoo.com
Thu Nov 15 06:23:40 PST 2012


There are times when casting away const is needed.  Structs that
define opCast can get in the way of this.  For instance, the cast
below fails, but I think it should always be allowed. So, if the
source type and cast type are the same except for const 
qualifiers,
there is no need to consider custom opCast members. Is a 
reasonable
suggestion for the language?

The cast here fails because it is considering custom opCast 
methods,
but that is not helpful.

Thanks
Dan

---------------------
import std.bitmanip;
void main() {
   const(BitArray) cba;
   cast()cba;
}



More information about the Digitalmars-d-learn mailing list