
I made the following wrapper over the Boost.InterProcessAllocator, #include <boost/interprocess/allocators/allocator.hpp> using namespace boost::interprocess; template<class T, class SegmentManager> class shared_allocator : public allocator< T, SegmentManager> { public: shared_allocator(SegmentManager *segment_mngr):allocator(segment_mngr) { } T* allocate(size_type count, void* hint = 0) { return allocator::allocate( count).get(); } void deallocate(T* ptr, size_type size) { allocator::deallocate(ptr,size); } }; and used the shared_allocator as the allocator to Boost.multi_array and I find it working fine. The boost multi_array allocates and deallocates the memory through shared_allocator. Am I doing something wrong here??Can it be used this way?? On Tue, Mar 18, 2008 at 8:13 PM, Ion Gaztañaga <igaztanaga@gmail.com> wrote:
sankar lingam wrote:
Can I create Boost multi_array in shared memory using Boost.InterProcess..? Can some one explain as to how this can be done.?
I tried providing the Boost InterProcess Allocator to the Boost multi_array but it gives the expected compiler error of casting an offset<ptr> to T* , when the multi_array tries to convert return type of the allocator allocate function(which is an offset<ptr>) to T*.
Can this problem be overcome by writing a custom stl compatible allocator wrapper over the interprocess allocator?
Regards, Sankar
MultiArray is not compatible with Boost.Interprocess. I've never tried that, so I can give any clue on how to solve this. It would interesting to make MultiArray compatible with non-raw pointers, but this is a issue MultiArray authors should address if they find it useful.
Regards,
Ion _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users