Boost logo

Boost Users :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2008-07-15 13:25:18


Eugen Stoianovici wrote:
> I'm having some trouble creating a vector in a shared memory segment
> (compilation errors)
>
> The code:
>
> [...]

This compiles fine in Visual 2003 and should not be problems with other
compilers. Which compiler/version are you using?

#include <boost/interprocess/containers/vector.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>

int main(){
     //Allocator for the event list
     typedef boost::interprocess::allocator
     <int,boost::interprocess::managed_shared_memory::segment_manager>
EventAllocator;

     //the in memory vector of events
     typedef boost::interprocess::vector<int, EventAllocator> EventList;

        boost::interprocess::managed_shared_memory
segment(boost::interprocess::open_only, "asdf");
     //is it already created?
     EventList* pEventList =
segment.find<EventList>("EVENTSEGMENT_NAME").first;

}

Regards,

Ion


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