Details
-
Epic
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
None
-
special-containers
-
Foundation PM Staging
Description
Here's a list of missing special-purpose containers that Qt might want to add, at least as private API, instead of duplicating STL containers.
Ideas
In no particular order:
- QSmallVector /
QSmallByteArray/ QSmallString: wrappers around std::array adding dynamic size. The difference to QVLA is that these containers cannot become larger than their template size (QVLA goes to the heap when prealloc is exceeded). - QList / QByteArray / QString versions with Small Buffer Optimization (SSO). Can use std::string and std::u16string for the latter, but we need sth for arbitrary T, too. The difference to QVLA is that the inline storage overlaps the (begin, alloc, size) triplet, and the prealloc isn't a template argument
- QEnumIndexedArray: a wrapper around std::array (or any indexed container, really, cf. QOptionalArray) with a given enum as index (instead of int/qsizetype/size_t. Type-safe version efficient replacement for `QMap/Hash<Enum,T>`.
- Ditto for QFlags? Probably ok for Read/Write/ReadWrite, but what about flags with dozens of entries?
- QOptionalArray / QOptionalVector: a std::array<std::optional> / std::vector<std::optional> wrapper that stores engagedness centrally in a bit field instead of wasting 7bits + padding for per-element storage with std::optional value_type. Also need a version of QEnumIndexedArray × QOptionalArray.
- QSmallIntSet: a version of QSet<int> optimized to store small integers as a bit-set instead of a vector. Optionally storing larger ints as a vector.E.g. for Qt::ItemRoles in changed() signals.
- A value-based QCache that doesn't need the cached items allocated on the heap (special usecase: QCache that holds items as shared_ptr so items aren't killed from under users; this would work with a value-based cache container, but it doesn't (without double indirection) using the current pointer-based QCache)
- ...
Each idea should first be converted into a separate issue / epic before implementing.