Missing comparison operators
Janice Caron
caron800 at googlemail.com
Fri Sep 28 20:44:22 PDT 2007
On 9/29/07, Gregor Richards <Richards at codu.org> wrote:
> bool didThisCompare(T)(T a, T b, bool performComparison)
> {
> if (performComparison) {
> bool result = (a == b);
> return true;
> } else {
> return false;
> }
> }
I don't get it. The line "bool result = (a == b);" can surely be
optimized away as it has absolutely no effect.
Following that optimization, the rest of the code turns into
bool didThisCompare(T)(T a, T b, bool performComparison)
{
if (performComparison) return true;
else return false;
}
...which is the same as...
bool didThisCompare(T)(T a, T b, bool performComparison)
{
return (performComparison) ? true : false;
}
...which is the same as...
bool didThisCompare(T)(T a, T b, bool performComparison)
{
return performComparison;
}
More information about the Digitalmars-d
mailing list