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

Konstantin Shegunov kshegunov at gmail.com
Mon Jan 2 15:20:16 CET 2017


On Mon, Jan 2, 2017 at 4:15 PM, René J. V. Bertin <rjvbertin at gmail.com>
wrote:
>
> > Note that all of this is constructed at *load* time, not at compile time
> and
> > not on first use.
>
> so it doesn't work like a classical static variable which is initialised
> only
> once, presuming you meant to say "not on first use *only*"?
>

It works exactly as a classic static variable with *nontrivial*
initialization. It's initialized only once before entering main().
This is in contrast with (e.g. heap allocated objects) that can be
initialized only and if used - "on first use".


> You already have a perfect hash in the case of a set of unique keys, like
> an
> enum, no?
>

Depends on the hashing function, but in the general case, no you don't.

Kind regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170102/4bb6dd3d/attachment.html>


More information about the Interest mailing list