On Tuesday, 11 November 2025 03:54:23 Pacific Standard Time xiaochaoyang0214 
wrote:
> Hello,
> 
> I'm sorry for the disruption, yet I've encountered a query while delving
> into the Qt container source code. Specifically, I'm curious as to why Qt 6
> employs std::map for QMap, but opts not to use std::vector for QList and
> QVector.

We've had our implementation of arrays since 2001, with Qt 3.0's QValueList, 
rewritten in Qt 4.0 as QList and QVector (still distinct types). Using our own 
backend allows us to implement COW more simply and also allows us to transform 
a QString into a QByteArray (or vice-versa, but usually memory constraints 
don't allow that to happen).

We had our own map implementation from that time too. However, by 6.0, it was 
felt that our implementation was deficient. Instead of rewriting it like we did 
for QHash, we decided it wasn't worth our time and simply wrapped std::map.

> Given that the Qt team has chosen std::map as the foundational
> implementation for QMap, I wonder why an analogous approach wasn't taken
> for QList and QVector. Why not simply rework them as straightforward
> wrapper layers atop std::vector, in a manner similar to how std::map serves
> as the basis for QMap?

Historical context: the question you need to ask is why we've rewritten QMap 
and not the other classes.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Principal Engineer - Intel DCG - Platform & Sys. Eng.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Interest mailing list
[email protected]
https://lists.qt-project.org/listinfo/interest

Reply via email to