D24262: Modernize code: use range-based loops & algorithms in more places

David Faure noreply at phabricator.kde.org
Sat Sep 28 20:55:13 BST 2019


dfaure added a comment.


  It's actually quite clear in my head, because I imagine the generated class. A captured variable in a lambda becomes a member variable. If it's a capture by value (which is what happens with [library]), it's a "plain value" member.
  So:
  
    bool Plugin::hasPlugin(const QString &library)
    {
        auto func = [&library](QObject* p) {
            return ...;
        });
    }
  
  becomes
  
    bool Plugin::hasPlugin(const QString &library)
    {
        class Closure {
            bool operator(QObject *p) const { return ...; }
            QString library;
        };
        auto func = Closure{library};
    }
  
  or something like that.

REPOSITORY
  R306 KParts

REVISION DETAIL
  https://phabricator.kde.org/D24262

To: kossebau, dfaure
Cc: dhaumann, 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/20190928/ff263822/attachment.html>


More information about the Kde-frameworks-devel mailing list