[Qt5-feedback] Lambdas

Thiago Macieira thiago at kde.org
Thu Jun 30 11:24:48 CEST 2011


Em Thursday, 30 de June de 2011, às 08:19:09, Konrad Rosenbaum escreveu:
> It feels much more natural to write something like mylsist.contains(...) 
> than qContains(mylist,...) - Qt is supposed to be object oriented after all.

It would be 

	if (qFind(mylist, [](Type t) { return t.isFoo(); }) != mylist.end())

But anyway, that's a question to OO developers: where do you draw the line? 
The purpose of a class is to protect and mutate the invariant, the internals 
that the class is holding. It's not supposed to do everything under the sun. 
For example, QDate will not have a method QDate QDate::firstFridayThisMonth() 
const.

I personally think that the kind of container operations you're asking for are 
just too specific to be part of the class. I'd prefer to have them outside. 

Yesterday, Konstantin was asking me for a 

	qFiltered(InputIterator, InputIterator, const T &value)

that would return a list containing just the values that matched. So are we 
going to add all of the QtConcurrent operations too? filtered, filterReduced, 
mapped, mapReduced?

-- 
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: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt.nokia.com/pipermail/qt5-feedback/attachments/20110630/0be53eba/attachment.bin 


More information about the Qt5-feedback mailing list