Boost C++ Libraries: Ticket #6533: Can't use map with incomplete type and interprocess allocator https://svn.boost.org/trac10/ticket/6533 <p> A boost::container::map using boost::interprocess::allocator cannot be instantiated with an incomplete value type, even though the allocator itself can be. </p> <p> Sample code: </p> <pre class="wiki">#include &lt;string&gt; #include &lt;boost/interprocess/allocators/allocator.hpp&gt; #include &lt;boost/interprocess/containers/map.hpp&gt; #include &lt;boost/interprocess/managed_shared_memory.hpp&gt; class Incomplete; typedef boost::interprocess::allocator&lt;std::pair&lt;std::string, Incomplete&gt;, boost::interprocess::managed_shared_memory::segment_manager&gt; Allocator; typedef boost::interprocess::map&lt;std::string, Incomplete, std::less&lt;std::string&gt;, Allocator&gt; IncompleteMap; class Incomplete { Allocator foo; // No error here IncompleteMap bar; // Error! }; </pre><p> The error occurs as part of the instantiation of boost::container::container_detail::is_convertible by boost::container::container_detail::impl::extract_version. Using using boost::is_convertible instead fixes the problem on Visual Studio 20103 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6533 Trac 1.4.3 Ion Gaztañaga Sat, 24 Mar 2012 16:38:38 GMT <link>https://svn.boost.org/trac10/ticket/6533#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6533#comment:1</guid> <description> <p> First of all, the code is wrong as the first parameter of std::pair should be const: </p> <p> boost::interprocess::allocator&lt;std::pair&lt;CONST std::string, Incomplete&gt;, </p> <p> Does this compile? My local version (for boost 1.50) compiles, so it will be fixed. </p> <p> #include &lt;string&gt; #include &lt;boost/interprocess/allocators/allocator.hpp&gt; #include &lt;boost/interprocess/containers/map.hpp&gt; #include &lt;boost/interprocess/managed_shared_memory.hpp&gt; </p> <p> class Incomplete; typedef boost::interprocess::allocator&lt;std::pair&lt;const std::string, Incomplete&gt;, </p> <blockquote> <p> boost::interprocess::managed_shared_memory::segment_manager&gt; Allocator; </p> </blockquote> <p> typedef boost::interprocess::map&lt;std::string, Incomplete, </p> <blockquote> <p> std::less&lt;std::string&gt;, Allocator&gt; <a class="missing wiki">IncompleteMap</a>; </p> </blockquote> <p> class Incomplete { </p> <blockquote> <p> Allocator foo; <em> No error here <a class="missing wiki">IncompleteMap</a> bar; </em> Error! public: Incomplete() </p> <blockquote> <p> : foo(0), bar(IncompleteMap::key_compare(), foo) </p> </blockquote> <p> {} </p> </blockquote> <p> }; </p> <p> int main() { </p> <blockquote> <p> Incomplete incomplete; return 0; </p> </blockquote> <p> } </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Fri, 24 Aug 2012 21:37:26 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6533#comment:2 https://svn.boost.org/trac10/ticket/6533#comment:2 <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">fixed</span> </li> </ul> <p> Fixed in Boost 1.50 </p> Ticket