[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: KSharedPtr bool conversion
From: David Faure <david.faure () insa-lyon ! fr>
Date: 1999-06-16 6:42:05
[Download RAW message or body]
On Wed, Jun 16, 1999 at 02:47:42AM +0200, Harri Porten wrote:
> Hi !
>
> I've got a problem compiling code that wants to use KSharedPtr's in
> boolean expressions (eg. KScript).
>
> Example with a fictious class:
>
> KSharedPtr<C> ptr;
>
> if(ptr)
> ;
>
> The (experimental) compiler says:
>
> shared.cpp:14: warning: choosing `KSharedPtr<C>::operator C *()' over
> `KSharedPtr<C>::operator const C *() const'
> shared.cpp:14: warning: for conversion from `KSharedPtr<C>' to `bool'
> shared.cpp:14: warning: because conversion sequence for the argument
> is better
> shared.cpp:14: warning: choosing `KSharedPtr<C>::operator C *()' over
> `KSharedPtr<C>::operator bool() const'
> shared.cpp:14: warning: for conversion from `KSharedPtr<C>' to `bool'
> shared.cpp:14: warning: because conversion sequence for the argument
> is better
>
> Using !!ptr or ptr.operator bool() works fine.
>
> Why is it trying to go this way of conversion ?
Wild guess : because the conversion needs to be added to ksharedptr.h ?
--
David FAURE
david.faure@insa-lyon.fr, faure@kde.org
http://www.insa-lyon.fr/People/AEDI/dfaure/index.html
KDE, Making The Future of Computing Available Today
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic