[Development] Removing QBool?
Gábor Lehel
illissius at gmail.com
Sun Jan 15 16:13:19 CET 2012
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.
Thanks,
~g
> --
> Thiago Macieira - thiago.macieira (AT) intel.com
> Software Architect - Intel Open Source Technology Center
> Intel Sweden AB - Registration Number: 556189-6027
> Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
More information about the Development
mailing list