[Interest] initialising a dictionary-type container instance with a static table?

Konstantin Shegunov kshegunov at gmail.com
Mon Jan 2 15:05:43 CET 2017

On Mon, Jan 2, 2017 at 4:02 PM, René J.V. Bertin <rjvbertin at gmail.com>
> Yes and no. Behind the scenes the code would of course look much like
> that, but in user code I was thinking along the lines of
> [snippet]

That's easily achieved by a rather trivial inline function returning a
reference to the hash (and all the ugly code is then hidden).

I considered what you suggested, of course. Writing such a generic
> interface makes sense if you can reuse it sufficiently often (or if you
> have really many entries to add), but rarely if you have just a few small
> dicts to create here and there.

Then I'd vote for Thiago's solution. The only drawback with it is that it
requires C++11 support, but that should be available pretty much anywhere
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170102/fb1f74e0/attachment.html>

More information about the Interest mailing list