[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: stupid C++ question / operator overloading / Qt
From:       Harri Porten <harri () trolltech ! com>
Date:       2001-02-27 19:27:13
[Download RAW message or body]

Dirk Mueller wrote:
> 
> Hi,
> 
> I noticed that Qt uses "int operator==(foo, bar)" while my C++ book
> (Stroustrup) says something about "bool operator==(foo, bar)".

"Almost only" for QChar, right ?

> Is it just
> sad that gcc doesn`t warn about this, or is it really useful/legal
> to do something like that ?
> 
> Are there compilers out there needing this specific return type ?

In old code you'll often find code that defines operator==() without any
return type at all. I guess that it comes from a time where bool didn't
exist and current compilers allow the defaulting to int for
compatibility reasons.

> I'm just wondering.. it seems to have a dramatic effect on code generation
> for g++/gcc when changing the return type to "bool". strange world.

Much more optimized I hope ? Unless someone holds me back I'll fix this
for 3.0 as 2.x is out of question for obvious reasons.

Harri.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic