Changeset 1350
- Timestamp:
- 11/30/09 04:45:43 (2 years ago)
- Files:
-
- trunk/docsrc/operatoroverloading.dd (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docsrc/operatoroverloading.dd
r989 r1350 15 15 $(LI $(LINK2 #Assignment, Assignment Operator Overloading)) 16 16 $(V2 17 $(LI $(LINK2 #Dot, Forwarding)) 17 $(DOT $(LI $(LINK2 #Dot, Forwarding))) 18 $(LI $(LINK2 #Dispatch, Forwarding)) 18 19 ) 19 20 $(LI $(LINK2 #Future, Future Directions)) … … 160 161 161 162 $(TR $(TD %) $(TD no) $(TD $(CODE opMod)) $(TD $(CODE opMod_r))) 162 163 $(V2 164 $(TR $(TD ^^) $(TD no) $(TD $(CODE opPow)) $(TD $(CODE opPow_r))) 165 ) 163 166 $(TR $(TD &) $(TD yes) $(TD $(CODE opAnd)) $(TD $(CODE opAnd_r))) 164 167 … … 560 563 561 564 $(V2 565 $(DOT 562 566 <h2><a name="Dot">Forwarding</a></h2> 563 567 … … 616 620 --- 617 621 ) 618 622 ) 623 624 $(V2 625 <h2><a name="Dispatch">Forwarding</a></h2> 626 627 $(P Member names not found in a class or struct can be forwarded 628 to a template function named $(CODE opDispatch) for resolution. 629 ) 630 631 --- 632 import std.stdio; 633 634 struct S 635 { 636 void opDispatch(string s, T)(T i) 637 { 638 writefln("S.opDispatch('%s', %s)", s, i); 639 } 640 } 641 642 class C 643 { 644 void opDispatch(string s)(int i) 645 { 646 writefln("S.opDispatch('%s', %s)", s, i); 647 } 648 } 649 650 struct D 651 { 652 template opDispatch(string s) 653 { 654 enum int opDispatch = 8; 655 } 656 } 657 658 void main() 659 { 660 S s; 661 s.opDispatch!("hello")(7); 662 s.foo(7); 663 664 auto c = new C(); 665 c.foo(8); 666 667 D d; 668 writefln("d.foo = %s", d.foo); 669 assert(d.foo == 8); 670 } 671 --- 672 ) 619 673 <h2><a name="Future">Future Directions</a></h2> 620 674
