[Development] Use of Standard Library containers in Qt source code
Marc Mutz
marc.mutz at kdab.com
Sat Jul 2 08:42:42 CEST 2016
On Friday 01 July 2016 22:05:45 Thiago Macieira wrote:
> I
> don't and I don't have time or interest in learning it. You will always see
> me write a for-loop to fill something rather than use std::fill.
This reminds of the party quip: "I was always bad at math in school <giggle>"
:)
But seriously:
This sort of sentiment fosters mistakes such as looping over
QVector::erase(it), turning a linear operation quadratic, and people trying to
reimplement binary search, leading to unstable search results that depend on
the size of the container. IOW: bugs.
Yes. I'm saying: Less STL use == more bugs.
We should instead foster the use of STL algorithms ("No raw loops"), not use
ignorance of the greatest C++ library ever written as a reason not to use what
it has to offer.
About APIs:
The STL has a great API. push_back() / back() vs. append() / last(), e.g. It
just happens to be largely consistent with itself instead of with Qt. But
camelCase is not intrinsically "better" than underscored_names, and I also
fail to see why first() should be intrinsically superior to front().
And as an aside: please stop claiming that "the Qt API was there before the
STL one".
Tell the world how the Qt containers looked when the STL was released. Go on.
If you want Qtsy containers, go back _there_. The current Qt containers are
more STLsy than Qtsy, and they're better for it.
Thanks,
Marc
--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - Qt, C++ and OpenGL Experts
More information about the Development
mailing list