If you look at QList implementation you'll find the following code for the clear:
...
Q_OUTOFLINE_TEMPLATE void QList<T>::clear()
{
*this = QList<T>();
}
...
...
Q_OUTOFLINE_TEMPLATE void QList<T>::clear()
{
*this = QList<T>();
}
...
To copy to clipboard, switch view to plain text mode
You might also look at implementation of assignment operator:
Q_INLINE_TEMPLATE QList<T> &QList<T>::operator=(const QList<T> &l)
{
if (d != l.d) {
QListData::Data *o = l.d;
o->ref.ref();
if (!d->ref.deref())
free(d);
d = o;
if (!d->sharable)
detach_helper();
}
return *this;
}
Q_INLINE_TEMPLATE QList<T> &QList<T>::operator=(const QList<T> &l)
{
if (d != l.d) {
QListData::Data *o = l.d;
o->ref.ref();
if (!d->ref.deref())
free(d);
d = o;
if (!d->sharable)
detach_helper();
}
return *this;
}
To copy to clipboard, switch view to plain text mode
So, as you can see, there are d-pointer's data copy and ref-counting operations.
Bookmarks