RFC: bool operators for some classes

Malte Starostik malte at kde.org
Sat Jan 4 01:31:03 GMT 2003


On Friday 03 January 2003 09:42, David Faure wrote:
> On Friday 03 January 2003 02:04, Malte Starostik wrote:
> > Some candidates apart from KMFI would be:
> > KSaveFile (status() != 0)
> > KTempFile (status() != 0)
> > KURL (isValid())
> > KURL::List (!isEmpty())
> > KColor (isValid())
> > KArchive (isOpened())
> > DCOPRef (!isNull())
> > KABC::(anything that has an isEmpty() member) (!isEmpty())
> > maybe some others
>
> Sounds like a good opportunity to write code with mistakes.
> Guess why QString doesn't have such an operator?
> Also ... should the KURL bool conversion be isValid or isEmpty? ....
> Code with "hidden meaning" is never easy to debug.

Good point. It might still make sense where the semantics are clear, but it's 
still probably too "hidden" and would be inconsistent then. Yes, probably the 
disadvantages are outweighing the possibility to use it with if(...).
It's a pity that statements like what Carsten wrote aren't allowed, but the 
comp.std.c++ folks had good points about why when I asked about that one a 
while back.

-Malte, convinced that it's too obscure for the libs.





More information about the kde-core-devel mailing list