Re: operator != not automatically defined when operator == is defined

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Shriramana Sharma wrote:

> operator-notequal.cpp:14: error: no match for ‘operator!=’ in ‘a != b’
> 
> Now there need conceivably be no definition for operator != other than 
> the not-ted value of what operator == gives, so why does gcc want me to 
> define operator != separately?
> 
> Similarly even if I define only operator !=, gcc will tell me to 
> separately define operator == if I want to use that.
> 
> For the pairs:
> 
> == and !=
>  > and <=
> < and >=
> 
> it is mathematically illogical to have any definition for each operator 
> in the pair which does not output same as the not-ted output of the 
> other operator in the pair,

In terms of mathematics, that's not even remotely true, particularly
for the inequalities (totally-ordered vs partially-ordered).

In C/C++ terms, it isn't necessarily true for the standard types; e.g. 
if floating-point values x and y are both NaN, then both x==y and x!=y
are false.

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux