Here is a solution using range-v3
https://github.com/cor3ntin/qt-iterate-over-associative-containers/blob/master/main.cpp
- there is of course room for improvement :)
2017-04-20 19:28 GMT+02:00 Matthew Woehlke :
> On 2017-04-20 13:18, Sergio Martins wrote:
> > On 2017-04-20 18:06, Matthew Woehlke
On 2017-04-20 13:18, Sergio Martins wrote:
> On 2017-04-20 18:06, Matthew Woehlke wrote:
>> for (auto i : qtEnumerate(my_hash))
>> do_stuff(i.key(), i.value());
>
> That doesn't work with temporaries, does it ?
No. Neither does std::add_const / qAsConst.
> Maybe something to fix in the C++
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
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
On Tuesday 18 April 2017 10:52:47 Olivier Goffart wrote:
> On Montag, 17. April 2017 18:48:26 CEST Marc Mutz wrote:
> > On Monday 17 April 2017 18:08:20 Thiago Macieira wrote:
> > > Em segunda-feira, 17 de abril de 2017, às 00:30:23 PDT, Marc Mutz
>
> escreveu:
> > > > The problem with QT_STRICT_I
On Montag, 17. April 2017 18:48:26 CEST Marc Mutz wrote:
> On Monday 17 April 2017 18:08:20 Thiago Macieira wrote:
> > Em segunda-feira, 17 de abril de 2017, às 00:30:23 PDT, Marc Mutz
escreveu:
> > > The problem with QT_STRICT_ITERATORS is _not_ that they are changing
> > > begin() and end(),
> >
Em segunda-feira, 17 de abril de 2017, às 09:48:26 PDT, Marc Mutz escreveu:
> On Monday 17 April 2017 18:08:20 Thiago Macieira wrote:
> > Em segunda-feira, 17 de abril de 2017, às 00:30:23 PDT, Marc Mutz
escreveu:
> > > The problem with QT_STRICT_ITERATORS is _not_ that they are changing
> > > beg
On Monday 17 April 2017 18:08:20 Thiago Macieira wrote:
> Em segunda-feira, 17 de abril de 2017, às 00:30:23 PDT, Marc Mutz escreveu:
> > The problem with QT_STRICT_ITERATORS is _not_ that they are changing
> > begin() and end(),
>
> Actually, it was. You can't use QT_STRICT_ITERATORS in one TU an
Em segunda-feira, 17 de abril de 2017, às 00:30:23 PDT, Marc Mutz escreveu:
> The problem with QT_STRICT_ITERATORS is _not_ that they are changing begin()
> and end(),
Actually, it was. You can't use QT_STRICT_ITERATORS in one TU and not in
other, regardless of exporting or not.
--
Thiago Maci
On Monday 17 April 2017 00:59:55 Thiago Macieira wrote:
> Em domingo, 16 de abril de 2017, às 15:16:54 PDT, Mark Gaiser escreveu:
> > Ohh, that's great!
> >
> >
> >
> > One question. Would it be possible and sane to - by default - provide
> > it as the patch implements it there, but with the addit
Em domingo, 16 de abril de 2017, às 15:16:54 PDT, Mark Gaiser escreveu:
> Ohh, that's great!
>
> One question. Would it be possible and sane to - by default - provide
> it as the patch implements it there, but with the addition of a define
> that can influence the behavior of the iterators?
Most
Em domingo, 16 de abril de 2017, às 15:09:16 PDT, Mark Gaiser escreveu:
> On Sun, Apr 16, 2017 at 5:53 PM, Thiago Macieira
>
> wrote:
> > Em domingo, 16 de abril de 2017, às 08:05:21 PDT, Mark Gaiser escreveu:
> >> That again makes me wonder, why did Qt diverge from that?
> >
> > We didn't diver
On Sun, Apr 16, 2017 at 9:48 PM, Samuel Gaist wrote:
>
>> On 16 Apr 2017, at 17:53, Thiago Macieira wrote:
>>
>> Em domingo, 16 de abril de 2017, às 08:05:21 PDT, Mark Gaiser escreveu:
>>> That again makes me wonder, why did Qt diverge from that?
>>
>> We didn't diverge. We never had that. The Qt
On Sun, Apr 16, 2017 at 5:53 PM, Thiago Macieira
wrote:
> Em domingo, 16 de abril de 2017, às 08:05:21 PDT, Mark Gaiser escreveu:
>> That again makes me wonder, why did Qt diverge from that?
>
> We didn't diverge. We never had that. The Qt style predates the Standard
> Library having relevance in
> On 16 Apr 2017, at 17:53, Thiago Macieira wrote:
>
> Em domingo, 16 de abril de 2017, às 08:05:21 PDT, Mark Gaiser escreveu:
>> That again makes me wonder, why did Qt diverge from that?
>
> We didn't diverge. We never had that. The Qt style predates the Standard
> Library having relevance in
Em domingo, 16 de abril de 2017, às 08:05:21 PDT, Mark Gaiser escreveu:
> That again makes me wonder, why did Qt diverge from that?
We didn't diverge. We never had that. The Qt style predates the Standard
Library having relevance in Qt. When the first QHash-like class was added, it
was just like
Qt wasn't initially designed with STL compatibility in mind ( in the early
2000, STL support was poor on most platforms and Qt actually predates c++98
- though QMap do not, I think). - I would argue that STL compatibility is
still an issue more often than not, but it's another discussion :)
As for
Very unlikely I'd say. Hashes are used all over the place in ppl' code and
making this change will break way too much to be sensible.
On Sun, Apr 16, 2017 at 6:05 PM, Mark Gaiser wrote:
> On Sun, Apr 16, 2017 at 4:44 PM, Corentin
> wrote:
> > Funny, a friend at kdab asked me about that exact qu
On Sun, Apr 16, 2017 at 4:44 PM, Corentin wrote:
> Funny, a friend at kdab asked me about that exact question a few minutes
> ago.
> The reason for the difference is most certainly an historical one ( and
> can't be changed because it would break quite a bit of code ).
>
> If you want the same beh
Funny, a friend at kdab asked me about that exact question a few minutes
ago.
The reason for the difference is most certainly an historical one ( and
can't be changed because it would break quite a bit of code ).
If you want the same behavior, you can create a proxy for your associative
container
Hi,
Take this simple example:
QHash test = {
{10, "aaa"},
{20, "bbb"},
{30, "ccc"}
};
for (const auto &entry: qAsConst(test)) {
qDebug() << entry;
}
It returns:
"aaa"
"ccc"
"bbb"
and the std::unordered_map version:
std::unordered_map test = {
{10, "aaa"},
{20,
21 matches
Mail list logo