Boost logo

Boost :

Subject: Re: [boost] boost::interprocess -- How do I construct a anonymous object ?
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-03-27 11:56:40


Oncaphillis wrote:
> Hi,
>
> I'm using boost::interprocess (1.37) and would like to construct
> a couple of anonymous objects. The idea is to construct a named
> object via
>
> Object *o segment.find_or_construct<Object>("theObject")();

http://www.boost.org/doc/libs/1_38_0/doc/html/interprocess/managed_memory_segments.html#interprocess.managed_memory_segments.managed_memory_segment_features.anonymous

****************************

using namespace boost::interprocess;

MyType *ptr =
    managed_memory_segment.construct<MyType>(anonymous_instance)
       (par1, par2...);

//Other construct variants can also be used
//(including non-throwing ones)

//We can only destroy the anonymous object via pointer
managed_memory_segment.destroy_ptr(ptr);

****************************

Best,

Ion


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk