Boost logo

Boost Users :

Subject: Re: [Boost-users] How to pass parameters to manage_shared_memory.construct() in Boost.Interprocess
From: Cuneyt (ctaskiran_at_[hidden])
Date: 2010-03-13 10:26:11


Steven Watanabe <watanabesj <at> gmail.com> writes:

>
> AMDG
>
> Cuneyt Taskiran wrote:
> > The interprocess document gives the prototype for `construct()` as
> >
> > MyType *ptr = managed_memory_segment.construct<MyType>("Name")
> > (par1, par2...);
> > but when I try
> >
> > MyVector *myvector = segment.construct<MyVector>("MyVector")(100,
> > alloc_inst);
> > I get compilation errors.
> >
>
> This is because vector doesn't have such a constructor.
> Try (100, 0, alloc_inst)
>
> In Christ,
> Steven Watanabe
>
Works like a charm, thanks a lot! I checked std::vector doc and saw that it's
constructor is
explicit vector ( size_type n, const T& value= T(), const Allocator& =
Allocator() );
so you're right.
Stupid question: if this is the constructor, how does
std::vector<int> v = std::vector<int>(100)
work?

Thanks a lot,
C


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