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