digitalmars.D.bugs - [documentation] bad C++ code
- Andrew Fedoniouk (25/25) Feb 09 2005 source: http://www.digitalmars.com/d/cpptod.html#operatoroverloading
- Stewart Gordon (11/26) Feb 10 2005 And even the D way is wrong. Should be:
- Walter (1/1) Feb 10 2005 Good catch. Fixed. -Walter
source: http://www.digitalmars.com/d/cpptod.html#operatoroverloading instead of: struct A { virtual int operator < (int i); virtual int operator <= (int i); virtual int operator > (int i); virtual int operator >= (int i); static int operator < (int i, A *a) { return a > i; } static int operator <= (int i, A *a) { return a >= i; } static int operator > (int i, A *a) { return a < i; } static int operator >= (int i, A *a) { return a <= i; } }; shall be written this: struct A { int operator < (int i); int operator <= (int i); int operator > (int i); int operator >= (int i); }; int operator < (int i, A &a) { return a > i; } int operator <= (int i, A &a) { return a >= i; } int operator > (int i, A &a) { return a < i; } int operator >= (int i, A &a) { return a <= i; }
Feb 09 2005
Andrew Fedoniouk wrote:source: http://www.digitalmars.com/d/cpptod.html#operatoroverloading<snip>shall be written this: struct A { int operator < (int i); int operator <= (int i); int operator > (int i); int operator >= (int i); }; int operator < (int i, A &a) { return a > i; } int operator <= (int i, A &a) { return a >= i; } int operator > (int i, A &a) { return a < i; } int operator >= (int i, A &a) { return a <= i; }And even the D way is wrong. Should be: struct A { int opCmp(int i); } Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Feb 10 2005