[Development] Removing QBool?

Giuseppe D'Angelo dangelog at gmail.com
Sun Jan 15 18:27:33 CET 2012


2012/1/15 Gábor Lehel <illissius at gmail.com>:
> 2012/1/7 Thiago Macieira <thiago.macieira at intel.com>:
>> On Saturday, 7 de January de 2012 01.03.50, David Faure wrote:
>>> Shouldn't we clean that up for Qt5 and just use a bool for the contains
>>> method  again? The Qt4 API ensures that nobody still has if (contains()==2)
>>> in their code anyway.
>>
>> I think it should be gone.
>>
>> For the few methods where a boolean is needed and arithmetic is wrong, the
>> suggestion is to use the RestrictedBool solution:
>>
>>        typedef int ClassName:: *RestrictedBool;
>
> Apologies for the off-topic:
>
> Is the RestrictedBool technique documented anywhere? What it does, how
> it works, why it works? I can see that it's using a member pointer to
> simulate a bool (presumably to avoid implicit casts to int and such),
> but not why this is preferable to a void* (fewer operations
> permitted?), and in particular why it has to be a pointer to a member
> of the specific class it is being used for instead of some
> globally-defined dummy class (even fewer operations permitted? but
> which ones?). Googling found nothing except the existing usage in
> QSharedPointer.

See f.i. http://www.artima.com/cppsource/safebool.html

Cheers,
-- 
Giuseppe D'Angelo



More information about the Development mailing list