97c2f9ab   
   From: ootiib@hot.ee   
      
   On Tuesday, 19 March 2013 08:00:03 UTC+2, Jerry wrote:   
   > Consider this:   
   >   
   > template   
   > int operator==(const X& x, const char *y)   
   > { return 1; }   
      
   Does that legacy compiler have 'bool'? If so use 'bool' as return   
   value of 'operator==(2)'. Otherwise you are confusing everybody, not   
   only compilers.   
      
   > template   
   > int operator==(const X& x, const Y& y)   
   > { return 2; }   
      
   You compare anything with anything? Pretty broad task.   
      
   > struct A {} a;   
   > main()   
   > {   
   > return a == "a";   
   > }   
      
   Well, if a tool is confused then that is good indication that what you   
   do is confusing to some people too.   
      
   > My question is: does anybody have a suggestion to munge the code so   
   > that the compiler will pick the same overload GCC does?   
      
   Not sure, but first thing I would get rid of the anything with   
   anything comparison. That is something that you are incapable of doing   
   anyway.   
      
   Second thing I would try is that:   
      
    template   
    bool operator==( X const& x, char const (&literal)[N])   
    { return true; }   
      
   It is likely best match comparing something with a string   
   literal. Also you get length of string literal as N.   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|