home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,937 of 33,346   
   =?ISO-8859-1?Q?=D6=F6_Tiib?= to Jerry   
   Re: Legacy compiler that should (but doe   
   19 Mar 13 05:17:55   
   
   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)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca