[Development] Meaning of Q_PRIMITIVE_TYPE?
Thiago Macieira
thiago.macieira at intel.com
Fri Mar 30 17:23:59 CEST 2012
On sexta-feira, 30 de março de 2012 16.54.09, Jedrzej Nowacki wrote:
> Then the only real problem I see is:
>
> QVarLengthArray<QUuid> array;
> array.resize(1);
>
> currently this is always true:
> array.at(0).isNull() == QUuid().isNull()
>
> with new definition it may be something else. It is not big deal, just is a
> bit unintuitive but if you take QFlags instead QUuid then it may break
> existing code in a nasty way, for example:
> QVarLengthArray<QFlags> array(1);
> ...
> array[0] |= MyFlag;
How about this one:
QVarLengthArray<int> array(1);
array[0] |= 0x80;
?
> How an user of QFlags can know if it is marked as primitive or not? The
Use of QVarLengthArray should *only* be done with primitive types, the fixes
applied to it during Qt 4.x lifetime notwithstanding. So the user must know
that before he uses that class. If he's not sure, use QVector.
Also, QVarLengthArray should zero-initialise, but it doesn't.
> So I'm afraid that marking QFlags as primitive may decrease performance in
> global picture. I believe that it is not a nice API. I will keep my -1
> because it is what I think about it. In the end, you can always override
> it, I'm fine with that ;-)
How would it decrease performance?
--
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120330/4ef8887c/attachment.sig>
More information about the Development
mailing list