[Development] Meaning of Q_PRIMITIVE_TYPE?
Olivier Goffart
olivier at woboq.com
Sat Mar 31 10:19:08 CEST 2012
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
>
> > 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.
More information about the Development
mailing list