D23902: [KCoreDirLister] replace deprecated foreach with range-for
David Faure
noreply at phabricator.kde.org
Fri Oct 4 16:53:52 BST 2019
dfaure added a comment.
In D23902#542037 <https://phabricator.kde.org/D23902#542037>, @ahmadsamir wrote:
> In D23902#542026 <https://phabricator.kde.org/D23902#542026>, @dfaure wrote:
>
> > For the record, JFBastien was actually wrong. Calling .begin() on a const return value does call the const overload. Testcase http://www.davidfaure.fr/kde/const_retval.cpp
>
>
> That looks like a failure in communication, either one of you _assumed_ something but didn't tell the other. :D
You and I are both entitled to our own opinion, I know what I asked and what the reply was :-P
(I tried to reach him afterwards via linkedin and cppcon slack, no success)
>> But returning const QList would inhibit move semantics, e.g. `QList<int> mylist = foo();` copies instead of moving.
>> So yeah, better not do that.
>
> And it would detach (I don't know why it feels like detaching for Qt containers is like a sword hanging over all, especially new, developers' heads; so implicit sharing is great, except you have to worry about the container detaching for the rest of its natural life... :)).
No, a copy doesn't detach. A non-const method call on a copy detaches.
And usually you don't have to worry about that. Detaching happens when it should, i.e. when modifying a copy, that's intended. The problem is range-for, which came up later, and which throws ease-of-use a little bit out of the window indeed.
REPOSITORY
R241 KIO
REVISION DETAIL
https://phabricator.kde.org/D23902
To: ahmadsamir, kde-frameworks-devel, dfaure
Cc: kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20191004/3f42a5d0/attachment.html>
More information about the Kde-frameworks-devel
mailing list