Details
-
Epic
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
None
-
container-assign
Description
Qt container are lacking the assign() overloads of STL containers:
- https://en.cppreference.com/w/cpp/string/basic_string/assign
- https://en.cppreference.com/w/cpp/container/vector/assign
These functions are a convenient way to assign new data while reusing the allocated memory:
std::string s; s.assign(p1, n1); // probably allocates s.assign(p2, n2); // may not allocate, if n1 >= n2 QByteArray s; s = QByteArray(p1, n1); // allocates s = QByteArray(p2, n2); // allocates, too, even if n2 <= n1
The STL views (string_view) don't have the assign() function, so it's basically the owning Qt containers:
- QByteArray
- QString
- QList
- QVLA
We should also look around the Qt code to find potential users of the new functions.
Attachments
Issue Links
- resulted from
-
QTBUG-105717 REG [5.15 -> 6.x] QByteArray::replace(0, size(), ptr, n) became ambiguous on 64-bit platforms
- Closed