Changeset 3810
- Timestamp:
- 07/26/08 15:33:57 (4 months ago)
- Files:
-
- trunk/tango/core/Variant.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/tango/core/Variant.d
r3200 r3810 95 95 } 96 96 97 template isInterface(T) 98 { 99 static if( is( T == interface ) ) 100 const isInterface = true; 101 else 102 const isInterface = false; 103 } 104 97 105 template isStaticArray(T) 98 106 { … … 279 287 this.value.obj = value; 280 288 } 289 else static if( isInterface!(T) ) 290 { 291 this.value.obj = cast(Object) value; 292 } 281 293 else 282 294 { … … 366 378 // Let D do runtime check itself 367 379 && !isObject!(T) 380 && !isInterface!(T) 368 381 // Allow implicit upcasts 369 382 && !canImplicitCastTo!(T)(type) … … 411 424 } 412 425 else static if( isObject!(T) ) 426 { 427 return cast(T)this.value.obj; 428 } 429 else static if( isInterface!(T) ) 413 430 { 414 431 return cast(T)this.value.obj; … … 614 631 } 615 632 633 // Test interface support 634 { 635 interface A {} 636 interface B : A {} 637 class C : B {} 638 class D : C {} 639 640 A a = new D; 641 Variant v = a; 642 B b = v.get!(B); 643 C c = v.get!(C); 644 D d = v.get!(D); 645 } 646 616 647 // Test doubles and implicit casting 617 648 v = 3.1413; … … 704 735 } 705 736 } 706












