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,012 of 33,346   
   red floyd to Michael   
   Re: why not implicit operator !=()?   
   15 Mar 12 14:56:52   
   
   ba9807fd   
   From: no.spam.here@its.invalid   
      
   On 3/15/2012 12:07 AM, Michael wrote:   
   > This has probably been asked before but...   
   >   
   > Is there a particular reason why when you define an operator ==()   
   > for a type:   
   >   
   > struct SomeType   
   > {   
   >    bool operator== (const SomeType&  rhs) const { return ...; }   
   > };   
   >   
   > ... that the compiler doesn't also go ahead and implicitly define   
   > operator !=() for you?   
   >   
   > This omission has become a pet peeve of mine lately...   
   >   
      
   Probably because operator== doesn't have to return a bool, or even   
   mean "equality operator".  You can use it for some other purpose,   
   much in the same way that operator<< doesn't do a shift for ostreams.   
      
   To be honest, that would probably be bad form, and horrendous to read,   
   but it's perfectly legal to do so.   
      
      
   --   
         [ 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