[Qt-interest] Placement new in Qt

Eric Clark eclark at ara.com
Wed Jul 1 18:49:07 CEST 2009


Hello All,


I noticed in the QList class that they are using the placement new operator. Does anyone know what Qt expects this to do?



template <typename T>

Q_INLINE_TEMPLATE void QList<T>::node_construct(Node *n, const T &t) {

    if (QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic) n->v = new T(t);

    else if (QTypeInfo<T>::isComplex) new (n) T(t);

    else *reinterpret_cast<T*>(n) = t;

}



In the second line of the function:



else if (QTypeInfo<T>::isComplex) new (n) T(t);



What does Qt expect it to do? Does it expect realloc to get called, or does it just expect "n" to be returned?



Thanks,

Eric

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090701/7f7870ef/attachment.html 


More information about the Qt-interest-old mailing list