Boost logo

Boost Users :

Subject: [Boost-users] boost vector including non standard objects
From: Sabine B (sabine565_at_[hidden])
Date: 2012-01-04 10:49:24


I would like to create a vector in shared memory which includes objects of
a class Listener*. Listener* was created by my
own and is therefore no standard.

When I try the following, using the boost interprocess library:
typedef boost::interprocess::allocator<Listener*,
managed_shared_memory::segment_manager> ShmemAllocator;
typedef boost::interprocess::vector<Listener*, ShmemAllocator> MyVector;
MyVector *ListenerVector;

managed_shared_memory segment(create_only, "MySharedMemory", 65536);
const ShmemAllocator alloc_inst(segment.get_segment_manager());
ListenerVector = segment.construct<MyVector>("ListenerVector")(alloc_inst);


The code works perfectly when I use a vector with integers, but it crashes
when I use a vector with
objects of my own class.

I wanted to ask if it is possible to create a boost vector holding a non
standard object and if so what I do wrong.

Thank you very much for your help!

Best regards,

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at