Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3690

Show
Ignore:
Timestamp:
06/30/08 06:56:36 (4 months ago)
Author:
larsivi
Message:

Fix isPointerType, thanks Jarrett, add unittests, thanks mandel, closes #1163

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tango/core/Traits.d

    r3453 r3690  
    108108 * Evaluates to true if T is a pointer type. 
    109109 */ 
    110 template isPointerType( T ) 
    111 
    112     const bool isPointerType = is( typeof(*T) ); 
    113 
    114  
     110template isPointerType(T) 
     111
     112        const isPointerType = false; 
     113
     114 
     115template isPointerType(T : T*) 
     116
     117        const isPointerType = true; 
     118
     119 
     120debug(UnitTest) { 
     121 
     122    unittest { 
     123 
     124        assert(isPointerType!(void*)); 
     125        assert(!isPointerType!(char[])); 
     126        assert(isPointerType!(char[]*)); 
     127        assert(!isPointerType!(char*[])); 
     128        assert(isPointerType!(real*)); 
     129        assert(!isPointerType!(uint)); 
     130         
     131        class Ham 
     132        { 
     133            void* a; 
     134        } 
     135         
     136        assert(!isPointerType!(Ham)); 
     137         
     138        union Eggs 
     139        { 
     140            void* a; 
     141            uint b; 
     142        }; 
     143         
     144        assert(!isPointerType!(Eggs)); 
     145        assert(isPointerType!(Eggs*)); 
     146         
     147        struct Bacon {}; 
     148         
     149        assert(!isPointerType!(Bacon)); 
     150 
     151    } 
     152
    115153 
    116154/**