Boost logo

Boost Users :

Subject: Re: [Boost-users] Explicit constructing boost intrusive list
From: Klaim - Joël Lamotte (mjklaim_at_[hidden])
Date: 2012-06-26 07:39:48


On Tue, Jun 26, 2012 at 4:39 PM, Allan Nielsen <a_at_[hidden]> 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



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net