Changeset 282:92e785261f30

Show
Ignore:
Timestamp:
08/08/08 09:19:05 (4 months ago)
Author:
Frank Benoit <benoit@tionex.de>
Children:

283:98fd89730a00 284:bb89fd34ec82

branch:
default
Message:

Fix: missing opEquals, toHash for ArrayWrapper?.
Fix: opEquals for ValueWrapper? in case of T is Object

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dwthelper/utils.d

    r280 r282  
    4242        array = data; 
    4343    } 
     44    public override int opEquals( Object o ){ 
     45        if( auto other = cast(ArrayWrapperT!(T))o){ 
     46            return array == other.array; 
     47        } 
     48        return false; 
     49    } 
     50    public override hash_t toHash(){ 
     51        return (typeid(T[])).getHash(&array); 
     52    } 
    4453} 
    4554 
     
    4958        value = data; 
    5059    } 
    51     public int opEquals( T other ){ 
    52         return value == other; 
    53     } 
    54     public int opEquals( Object other ){ 
    55         if( auto o = cast(ValueWrapperT!(T))other ){ 
    56             return value == o.value; 
    57         } 
    58         return false; 
     60    static if( is(T==class) || is(T==interface)){ 
     61        public int opEquals( Object other ){ 
     62            if( auto o = cast(ValueWrapperT!(T))other ){ 
     63                return value == o.value; 
     64            } 
     65            if( auto o = cast(T)other ){ 
     66                if( value is o ){ 
     67                    return true; 
     68                } 
     69                if( value is null || o is null ){ 
     70                    return false; 
     71                } 
     72                return value == o; 
     73            } 
     74            return false; 
     75        } 
     76    } 
     77    else{ 
     78        public int opEquals( Object other ){ 
     79            if( auto o = cast(ValueWrapperT!(T))other ){ 
     80                return value == o.value; 
     81            } 
     82            return false; 
     83        } 
     84        public int opEquals( T other ){ 
     85            return value == other; 
     86        } 
     87    } 
     88    public override hash_t toHash(){ 
     89        return (typeid(T)).getHash(&value); 
    5990    } 
    6091}