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,019 of 33,346    |
|    Marc to All    |
|    Re: why not implicit operator !=()?    |
|    16 Mar 12 06:34:25    |
      From: marc.glisse@gmail.com              Qi wrote:              > On 2012-3-15 15:07, Michael wrote:       >>       >> ... that the compiler doesn't also go ahead and implicitly define       >> operator !=() for you?       >       > Though logically "not ==" is almost same as "!=", the implementation       > maybe quite different, especially for performance.       >       > To implement ==, you need to verify all member fields are equal.       > But for !=, you will return when you get first non-equal field.              Er, no, for both you stop as soon as you find a non-equal field. The       only difference is that in one case this early exit returns false and       in the other true...              > Not sure if this is the primary reason the compile doesn't implicit       > add !=, but if the compiler add !=, there will be performance issue.              I have often seen operator== return something that is not bool, but I       can't remember ever seing operator!= do something significantly       different from !operator==.                     --        [ 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