[Development] QHash for Qt 6
Martin Smith
Martin.Smith at qt.io
Tue Dec 24 11:28:04 CET 2019
>However, instead of adding
>template<class T> bool qIsEmpty(const T &t) { return t.empty(); }
>we keep discussing how ugly std is=)
But that's kind of ugly too. I read it as qlsEmpty(), not qIsEmpty(). See what I mean? On of those is a lower case L.
How about a new approach to adding free functions:
template<class T> bool isEmptyQt(const T &t) { return t.empty(); }
martin
________________________________________
From: Development <development-bounces at qt-project.org> on behalf of Иван Комиссаров <abbapoh at gmail.com>
Sent: Tuesday, December 24, 2019 10:43 AM
To: Kevin Kofler
Cc: development at qt-project.org
Subject: Re: [Development] QHash for Qt 6
That’s why in Qbs we have «stlutils» header [0]
I think, I already proposed in one of the similar Qt vs std threads an addition of free functions to make life easier with std:: containers. As far as I remember, Thiago’s main argument against using std::vector was that .empty() looks ugly (and I completely agree with that!).
However, instead of adding
template<class T> bool qIsEmpty(const T &t) { return t.empty(); }
we keep discussing how ugly std is=)
PS: note, that there is std::empty [1] (which can be used with c-arrays as well) in the standard library, so, again, Qt kind of misses feature parity here
[0] https://github.com/qbs/qbs/blob/master/src/lib/corelib/tools/stlutils.h
[1] https://en.cppreference.com/w/cpp/iterator/empty
24 дек. 2019 г., в 12:12, Kevin Kofler <kevin.kofler at chello.at<mailto:kevin.kofler at chello.at>> написал(а):
Иван Комиссаров wrote:
Well, every time I use (or try to use) QStringView I encounter the problem
of missing methods/functionality. The same applies to the Qt containers.
It's funny because I have that issue each time I am forced to work with
somebody else's STL containers. :-) (Sometimes, <algorithms> can help, e.g.,
to find an element in an std::vector, but its arcane syntax with the pair of
iterators is a pain compared to just calling a method such as
QVector::contains.)
Kevin Kofler
_______________________________________________
Development mailing list
Development at qt-project.org<mailto:Development at qt-project.org>
https://lists.qt-project.org/listinfo/development
More information about the Development
mailing list