<div>&nbsp;&nbsp;&nbsp; </div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I made the following wrapper over the Boost.InterProcess Allocator,</div>
<div>&nbsp;</div>
<div><font color="#0000ff" size="2">
<p>#include</p></font><font size="2"> </font><font color="#a31515" size="2">&lt;boost/interprocess/allocators/allocator.hpp&gt;</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">&lt;</font><font color="#0000ff" size="2">class</font><font size="2"> T, </font><font color="#0000ff" size="2">class</font><font size="2"> SegmentManager&gt;</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&lt; T, SegmentManager&gt;
<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>&nbsp;</p>
<p>and used the shared_allocator as the allocator to Boost.multi_array and </p>
<p>I find it working fine. The&nbsp;boost multi_array&nbsp;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>&nbsp;</div>
<div class="gmail_quote">On Tue, Mar 18, 2008 at 8:13 PM, Ion Gazta�aga &lt;<a href="mailto:igaztanaga@gmail.com">igaztanaga@gmail.com</a>&gt; 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>&gt;<br>&gt;<br>&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Can I create Boost multi_array in shared memory using<br>&gt; Boost.InterProcess..?<br>&gt; Can some one explain as to how this can be done.?<br>
&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;I tried providing the Boost InterProcess Allocator to the<br>&gt; Boost multi_array but it gives the<br>&gt; expected compiler error of casting an offset&lt;ptr&gt; to T* , when<br>&gt; the multi_array tries to convert<br>
&gt; return type of the allocator allocate function(which is an<br>&gt; offset&lt;ptr&gt;) to T*.<br>&gt;<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp;Can this problem be overcome by writing a custom stl<br>&gt; compatible allocator wrapper over the interprocess allocator?<br>
&gt;<br>&gt; Regards,<br>&gt; Sankar<br><br></div></div>MultiArray is not compatible with Boost.Interprocess. I&#39;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>