As I understand the quicksort, if the shuffling of the members is done with the copy ctor, you're going to be pretty disappointed by what O(n ln n) really means. So I decided to test qSort
with
QList<QObject> mylist; //Yes, I know this isn't feasible, I just wanted to find where the copy ctor is being used
qSort(list);
and got hit with those
'QObject::QObject(const QObject&)' is private
errors. From what I can tell, the problem begins with the begin()
method, because if I have
list.begin();
the compiler error indicates that this qlist.h line is somehow trying to use the copy ctor:
inline void detach() { if (d->ref != 1) detach_helper(); }
I realize I could make the list's members pointers, then implement the lessThan
function, but that's not very convenient for this code base. So how can I avoid using the copy ctor when qSort
operates on a list of objects?
I'm using Qt 4.8 on Linux 64-bit and 32-bit.