[Interest] QMap::keys() / Qt6

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Wed Jan 3 20:08:34 CET 2018


Am 02.01.2018 um 23:24 schrieb Giuseppe D'Angelo:
> 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".
Correct - but I now added the four lines because I could not find a 
second place during a short search so I had no reason to add a 
function... but still thinking it would be a good idea to have such 
helpers somewhere.

Christian

btw: still on interest, but now it's too late ;)



More information about the Interest mailing list