[Development] Use of Standard Library containers in Qt source code

André Somers andre at familiesomers.nl
Mon Jul 4 09:47:12 CEST 2016



Op 04/07/2016 om 08:41 schreef Thiago Macieira:
> On segunda-feira, 4 de julho de 2016 08:14:21 PDT Julien Blanc wrote:
>> Following Stephen Kelly’s mails, I’m convinced that instead of wrapping
>> stl containers, implementing a free function qIsEmpty is less work and
>> addresses all your readability concerns.
> But it is uglier
Actually, I disagree with that. As someone who has come to appreciate 
STL after growing up in the Qt world, I think that memberfunctions are 
over-used. Emptyness is a concept that can be applied to many objects, 
and it would be nice if I don't need a different function for all of 
them. The problem with implementing things in a member function is that 
the implementation will be specific for that class only, even if it did 
not really have to be. You end up re-creating algorithms for no good 
reason. And yes, that mistake has been made in the standard libraries as 
well.

Note that there is work going on by Bjarne S. on a universal calling 
conventions. As in: making calling a free function on an object and 
calling a member function on that object to be interchangeble in syntax.

> and does not help with .append() for .push_back().
>
Why not? You could do the same thing there if you prefer.

append(Container c, T item) can be made to work for both STL and Qt 
containers I think?

André



More information about the Development mailing list