Il 02/01/2018 18:37, Jason H ha scritto:
Is it possible to add a helper function for this somewhere (or is it already available) or another easier way?I complained about a lack of a generic iterator class back in the spring of last year[1]. Thiago seems to have one waiting for Qt6, because as a developer, I don't want to to care what kind of iterable you pass to me, I just want to iterate on it.
But this doesn't really require a "generic iterator class", does it? The function looked for here is really some variation around this:
template <typename K, typename V>
auto mapKeysToVector(const QMap<K, V> &map)
{
QVector<K> result;
result.reserve(map.size());
std::copy(map.keyBegin(), map.keyEnd(), std::back_inserter(result));
return result;
}
The question is more broad and about how to avoid similar functions popping up everywhere in Qt codebase. I don't have a good answer for that except for "please start collecting them somewhere in the QtPrivate namespace".
My 2 c, -- Giuseppe D'Angelo | [email protected] | Senior Software Engineer KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908 KDAB - Qt, C++ and OpenGL Experts
smime.p7s
Description: Firma crittografica S/MIME
_______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
