Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Interprocess: Can I share the multi_index array between processes?
From: joaquin_at_[hidden]
Date: 2010-04-07 03:24:14


Arman Khalatyan escribió:
> Hi,
> Thanks for your detailed explanations.
> I was paying with your nice example.
> Currently my structure is keeping only several floats, ints and
> unsigned ints.
> Following the Interprocess documentation, as you wrote, I can put
> them directly
> into shared memory:
>
> [...]
>
> Now I am trying to access the memory from client:
> shared_memory_object shm (open_only, "shared_memory", read_only);
>
> //Map the whole shared memory in this process
> mapped_region region(shm, read_only);
>
> //Check that memory was initialized to 1
> const particlesID_set *P =
> static_cast<particlesID_set*>(region.get_address());
>
> //const particlesID_set::nth_index<1>::type L1_ID_index =
> (*P).get<1>();// This does not compile, Why?

It is

  const particlesID_set::nth_index<1>::type& L1_ID_index = ...

Note the added '&'; this is explained for instance at the final paragraph of

http://www.boost.org/libs/multi_index/doc/tutorial/basics.html#multiple_sort

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo


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