On 2017-04-20 18:06, Matthew Woehlke wrote:
On 2017-04-16 10:44, Corentin wrote:
If you want the same behavior, you can create a proxy for your
associative
container instance, with a custom iterator whose operator*() returns a
std
pair ( or a QPair ) - quite a bit of boilterplate code.
...or use
https://github.com/Kitware/qtextensions/blob/master/core/qtEnumerate.h.
Rather than returning a pair (which may add overhead), it creates a
proxy that just returns the iterator, so you can write:
for (auto i : qtEnumerate(my_hash))
do_stuff(i.key(), i.value());
That doesn't work with temporaries, does it ?
Maybe something to fix in the C++ language, since the usual
lifetime-extension tricks don't help in this case.
Regards,
--
Sérgio Martins | [email protected] | Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel: Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - The Qt, C++ and OpenGL Experts
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development