Boost C++ Libraries: Ticket #7654: offset_ptr can't be evaluated a pointer to a container in shared memory https://svn.boost.org/trac10/ticket/7654 <p> i created a container(boost::container::set) in shared memory by managed_shared_memeory::construct,i wanted to put the pointer of container into a offset_ptr,codes as: typedef boost::container::set&lt;int, less&lt;int&gt;, int_allocator_type&gt; values_type; values_ptr_ = segment_manager_-&gt;construct&lt;values_type&gt;( boost::interprocess::anonymous_instance )( std::less&lt;int&gt;(), int_allocator_type( segment_manager_ ) ); </p> <p> when compiling: error C2512: 'boost::interprocess::allocator&lt;T,<a class="missing wiki">SegmentManager</a>&gt;' : no appropriate default constructor available </p> <blockquote> <p> with [ </p> <blockquote> <p> T=boost::container::container_detail::rbtree_node&lt;unsigned <span class="underline">int64,boost::interprocess::offset_ptr&lt;void&gt;&gt;, <a class="missing wiki">SegmentManager</a>=segment_manager_type </span></p> </blockquote> <p> ] </p> </blockquote> <p> the related codes as: template &lt;class T&gt; </p> <blockquote> <p> offset_ptr( T *ptr </p> <blockquote> <p> , typename ipcdetail::enable_if&lt; ipcdetail::is_convertible&lt;T*, <a class="missing wiki">PointedType</a>*&gt; &gt;::type * = 0) </p> </blockquote> <p> { this-&gt;set_offset(static_cast&lt;<a class="missing wiki">PointedType</a>*&gt;(ptr)); } </p> </blockquote> <p> template &lt;bool B, class T = void&gt; struct enable_if_c { </p> <blockquote> <p> typedef T type; </p> </blockquote> <p> }; </p> <p> template &lt;class T&gt; struct enable_if_c&lt;false, T&gt; {}; </p> <p> template &lt;class Cond, class T = void&gt; struct enable_if : public enable_if_c&lt;Cond::value, T&gt; {}; </p> <p> template &lt;class Cond, class T = void&gt; struct disable_if : public enable_if_c&lt;!Cond::value, T&gt; {}; </p> <p> template &lt;class T, class U&gt; class is_convertible { </p> <blockquote> <p> typedef char true_t; class false_t { char dummy<a class="changeset" href="https://svn.boost.org/trac10/changeset/2" title="Add Boost Disclaimer">[2]</a>; }; static true_t dispatch(U); static false_t dispatch(...); static T trigger(); public: static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t); </p> </blockquote> <p> }; </p> <p> i thougnt that T and U are values_type*,it's unnecessary to instantiate a values_type,but why called allocator's constructor ? </p> <p> the boost::container's allocator must have a default constructor,but,in fact,boost::interprocess::allocator is stateful,its constructor need the pointer to segment_manager。is it a bug? or my codes is fault? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7654 Trac 1.4.3 hongchenbo@… Wed, 07 Nov 2012 01:24:40 GMT <link>https://svn.boost.org/trac10/ticket/7654#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7654#comment:1</guid> <description> <p> sorry,i forgot to tell you i used visual studio 2010.the problem present in boost1.51 and boost1.52. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Fri, 28 Dec 2012 22:55:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7654#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7654#comment:2</guid> <description> <p> I can't reproduce the bug. Could you provide a full compilable example, please? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Thu, 23 May 2013 22:26:09 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7654#comment:3 https://svn.boost.org/trac10/ticket/7654#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> </ul> <p> Please reopen the bug if you reproduce the issue and send a test case if possible. </p> Ticket