Unsolved QList<double> memory model ?
-
Hello,
I have read in the documentation that for all types smaller or equal than a pointer a QList stores the values directly and not with pointers.
That means for a 32-bit compiler, doubles will be stored with pointer. Is this correct?If yes, how can I avoid it, because for doubles this an enormous overhead and makes no sense.
(Besides standard C-math-vector-functions will not run.) -
That's correct. QList is not the best container if you care about contiguous memory layout. QVector is far better for that.
If you want a list anyway then either switch to 64bit (which we all should've done long ago IMHO) or don't use QList (maybe a std::list instead?). -
Hi,
To add to Chris, here you can find a very good analysis of Qt's and their STL's counterparts containers.
-
Hi @Chris-Kawa
That is a pity. 64 bit is no way for me. I have subclassed the QList to integrate some useful additional functions, therefore I must do the same for QVector. I must think about it, maybe there is a way to write this code only once with templates.
I there really not trick to force the QList to use contiguous layout for doubles ? -
Hi @SGaist,
thank for the tip, I will read it tomorrow.