Creating a QList of a given size, or resizing it to a given size, will
always value-initialize its elements. This commit adds support for
uninitialized construction and resizes. The intended use case is using a
QList as storage-to-be-overwritten:
QList<int> list(size, Qt::Uninitialized);
fillWithData(list.data(), list.size);
How do we define "uninitialized":
1) if T is constructible using Qt::Uninitialized, use that;
2) otherwise, default-construct T.
In detail:
1) covers (Qt-ish) datatypes that have a default constructor that
initializes them, but also a dedicated constructor that doesn't
initialize (e.g. QPoint, QQuaternion, ...).
2) covers everything else. Default initialization of scalars and
trivially constructible datatypes will leave them uninitialized.
A type which isn't trivially constructible will still get its default
constructor called (and possibly actually gets initialized); we can't
really do better than that, as we still have to construct objects and
start their lifetimes.
[ChangeLog][QtCore][QList] Added support for uninitialized construction
and resizing.
Change-Id: I32c285c7dddbf7e01475943f24e14e824bb13090
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>