KDE/kdelibs/kdeui
Thiago Macieira
thiago at kde.org
Mon Sep 15 07:36:56 BST 2008
Ingo Klöcker wrote:
>Unfortunately, this idea doesn't work because of
> T QList<T>::value( int i ) const
>i.e. QList<QAction *>::value( int i ) does not return a const QAction *,
>but a QAction *. All other const methods of QList<T> return a const T
>&, though.
Just in case someone is wondering:
QList<T>::value() returns a copy of the element, whereas
QList<T>::operator[]() returns a reference to the item. And copies don't
have to be const.
Now, even more, please note that the function:
const T &QList<T>::operator[](int i) const
when expanding with T = QAction*, expands to:
QAction * const &QList<QAction *>::operator[](int i) const
Note the position of the const: it's 'QAction * const', not 'const QAction
*' like Ingo and Michael are thinking.
You really want QList<const QAction *>.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080915/dfad87ba/attachment.sig>
More information about the kde-core-devel
mailing list