[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

Marc Mutz marc.mutz at kdab.com
Fri Jul 10 12:10:18 CEST 2015


It might be more instructive to describe these by the effects they have:

On Friday 10 July 2015 10:05:40 Curtis Mitch wrote:
> Q_PRIMITIVE_TYPE

Imples Q_MOVABLE_TYPE. In addition, the default ctor is replaced by memset(0) 
and the dtor call with nothing.

> Q_MOVABLE_TYPE

Has nothing to do with C++11 move semantics!

The default ctor and the dtor are run, but for relocating an object in memory, 
e.g. when growing a container, memcpy is used and the old memory does not have 
it's dtors called. IOW: realloc() can be used on array of these types.

> Q_COMPLEX_TYPE (the default)

the default ctor and dtor are called. In addition, for relocating the type in 
memory, the copy ctor is used (and the dtor is called on the old memory). The 
copy ctor could be replaced by the move ctor, but our containers don't do 
that, yet.

Thanks,
Marc

PS: the docs for QList are an outright lie. QList is not a good default 
container, and it does not produce less executable code than QVector, but 
changing the docs is a lot of work and I prefer to focus on fixing the code. 
But if someone would give the docs a good dose of reality back, I'd be more 
than willing to review such a change.

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts



More information about the Development mailing list