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,016 of 33,346    |
|    Seungbeom Kim to All    |
|    Re: why not implicit operator !=()?    |
|    16 Mar 12 06:23:40    |
      From: musiphil@bawi.org              On 2012-03-15 13:52, 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.              In the usual sense, equality means all pairs of members are equal,       which means you can return false as soon as one pair of members are       unequal, which is exactly when you can return true for inequality.       The worst case is when all members are equal, in which case (and in       which case only) both equality and inequality should compare all members.              Therefore, equality and inequality are symmetric performance-wise,       and if equality is implemented smart enough, so is the inequality       implemented in terms of that equality.              --       Seungbeom Kim                      [ 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