-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters