[Development] Meaning of Q_PRIMITIVE_TYPE?

jedrzej.nowacki at nokia.com jedrzej.nowacki at nokia.com
Tue Apr 3 09:52:37 CEST 2012


Hi,

> The problem is that users are not usually aware whether a class is
> primitive or not.

And with Q_PRIMITIVE_TYPE they have no way to check if a class is primitive or not, moreover it may be changed by us even in a minor releases. How bad it is?

Cheers,
  Jędrek
________________________________________
From: development-bounces+jedrzej.nowacki=nokia.com at qt-project.org [development-bounces+jedrzej.nowacki=nokia.com at qt-project.org] on behalf of Knoll Lars (Nokia-MP/Oslo)
Sent: Saturday, March 31, 2012 2:37 PM
To: olivier at woboq.com; development at qt-project.org
Cc: thiago.macieira at intel.com
Subject: Re: [Development] Meaning of Q_PRIMITIVE_TYPE?

On 3/31/12 10:19 AM, "ext Olivier Goffart" <olivier at woboq.com> wrote:

>On Friday 30 March 2012 15:35:40 Thiago Macieira wrote:
>> On sexta-feira, 30 de março de 2012 18.41.46, Olivier Goffart wrote:
>> > On Friday 30 March 2012 12:23:59 Thiago Macieira wrote:
>> > > 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.
>> >
>> > That is wrong.  QVarLenghtArray can be use with every types.
>>
>> That statement ^^^
>>
>> > > Also, QVarLengthArray should zero-initialise, but it doesn't.
>> >
>> > It is documented not to.
>>
>> And this statement ^^^
>>
>> Are in contradiction. If it doesn't zero-initialise, then it doesn't
>> initialise. Then using it for non-PODs is dangerous.
>>
>> If it supports any type, then it must initialise them all.
>
>
>It initialize the types that are not marked as Q_PRIMITIVE_TYPE.
>The documentation even says that it is only primitive types that are not
>initialized

The problem is that users are not usually aware whether a class is
primitive or not.
>
>>
>> > But yes, it probably should.  (we can add a Qt::Uninitialized
>>overload if
>> > we need it)
>>
>> I'd rather we removed support for non-primitives. The class wasn't
>>designed
>> for that.
>
>It was designed for that, and works well.

As the guy who wrote the first implementation: Originally it wasn't. It
was only there to help us place an array of primitive types on the stack.
It was basically there only to work around the fact that C++ doesn't allow
variable length arrays on the stack.


Cheers,
Lars

_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


More information about the Development mailing list