is is cast on hash required

Dan dbdavidson at yahoo.com
Thu Nov 15 04:27:00 PST 2012


Is there a way around the cast below to see if ci is i?
If not, is there already a standard template method that does 
DeepUnqual.
Finally, if not a workaround is this safe?

Thanks
Dan
----------------------
import std.traits;

void main() {
   const(int[string]) ci;
   int[string] i;
   // FAILS TO COMPILE if(ci is i) { }
   if(cast(DeepUnqual!(typeof(ci)))ci is 
cast(DeepUnqual!(typeof(i)))i) {  }
}

template DeepUnqual(T) {
   static if(isAssociativeArray!T) {
     alias Unqual!(Unqual!(ValueType!T)[Unqual!(KeyType!T)]) 
DeepUnqual;
   } else static if(isDynamicArray!T) {
     alias Unqual!(Unqual!(ArrayElementType!T)[]) DeepUnqual;
   } else static if(isPointer!T) {
     alias Unqual!(PointerTarget!T) * DeepUnqual;
   } else {
     alias Unqual!T DeepUnqual;
   }
}



More information about the Digitalmars-d-learn mailing list