On Tue, Jun 26, 2012 at 4:39 PM, Allan Nielsen
<a@awn.dk> wrote:
Is there any achieve this or something similar when using
intrusive::list as a global resource?
If you can use C++11 lambda expressions, you can do something like this:
static const ContainerType GLOBAL_REGISTRY = []() -> ContainerType // lambda that return a ContainerType
{
ContainerType my_container;
// fill the container however you want, done only once
return my_container;
}(); // don't forget the () to execute the lambda on initialization
It's better than a free function because you are sure it cannot be called by any other code.
Hope it helps.
Joel Lamotte