[Interest] move methods in QList

Philippe philwave at gmail.com
Wed Oct 11 23:56:57 CEST 2017


On Wed, 11 Oct 2017 22:32:49 +0200
Elvis Stansvik <elvstone at gmail.com> wrote:

> Could others chime in here. If you were to start a project today, what
> focus would you have wrt to containers? Would you do your utmost to
> stay with std containers? Strive to use Qt containers, but avoid QList
> as much as possible? Or even not be afraid of QList use at all, for
> the convenience of being able to pass it to some Qt API later on?

If you need flexibility, easy of use, and consistent xplatform, use Qt
containers.

Now, if you want to put emphasis on speed, then you can't avoid to study
carefully the APIs.
For example, "std::vector faster than QVector" is not always true or
easy.
For instance, for std::vector to be fast for random insertions, you need
to implement move constructors *and* have them noexcept.
Are you always ready for this?
Compare this with the ease and power of the Qt  trait Q_MOVABLE_TYPE.

Finally, if speed is really important for you, you need one step further
and take care about memory allocation. In that case, forget both Qt and
std and use, for example, eastl (https://github.com/electronicarts/EASTL)
which provides better support than std for custom memory allocators.

Philippe




More information about the Interest mailing list