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,010 of 33,346   
   Pete Becker to Michael   
   Re: why not implicit operator !=()?   
   15 Mar 12 13:51:29   
   
   ba9807fd   
   From: pete@versatilecoding.com   
      
   On 2012-03-15 07:07:55 +0000, Michael said:   
      
   > 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...   
   >   
      
   More generally, if you define operator== and operator<, the rest of the   
   comparison operators are defined in the namespace std::rel_ops, in the   
   header .   
      
   #include    
   using std::rel_ops;   
      
   --   
     Pete   
   Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The   
   Standard C++ Library Extensions: a Tutorial and Reference   
   (www.petebecker.com/tr1book)   
      
      
         [ 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