Hi,

> How about this one:
> QVarLengthArray<int> array(1);
> array[0] |= 0x80;

This is a bit different because you can expect from users that they know about 
POD and in general about variable initialization in C++. QFlags, QUuid have 
default constructor, int hasn't.

> Also, QVarLengthArray should zero-initialise, but it doesn't.
I like this feature it allows to avoid double initialization in some cases, but 
maybe it is not the most intuitive behavior. Anyway it is a bit out of scope. 
 
Cheers,

  Jędrek

________________________________________
From: [email protected] 
[[email protected]] on behalf of ext 
Thiago Macieira [[email protected]]
Sent: Friday, March 30, 2012 5:23 PM
To: [email protected]
Subject: Re: [Development] Meaning of Q_PRIMITIVE_TYPE?

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
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to