Boost C++ Libraries: Ticket #1996: "void" template specialisation for the pool allocators https://svn.boost.org/trac10/ticket/1996 <p> It might be reasonable to add a template specialisation for the allocator classes "pool_allocator&lt;T,..&gt;" and "fast_pool_allocator&lt;T,..&gt;" with T=void? </p> <p> The library boost::multi_index, e.g., currently (version 1.35.0) uses the allocator&lt;void&gt; notation in its generic code (expecting a "default allocator"). </p> <p> In section 20.4.1 [lib.default.allocator] of the C++ standard the following specialisation is defined for class std::allocator as follows: </p> <p> &lt;code&gt; template &lt;class T&gt; class allocator; <em> specialize for void: template &lt;&gt; class allocator&lt;void&gt; { public: </em></p> <blockquote> <p> typedef void* pointer; typedef const void* const_pointer; <em> reference-to-void members are impossible. typedef void value_type; template &lt;class U&gt; struct rebind { typedef allocator&lt;U&gt; other; }; </em></p> </blockquote> <p> }; &lt;/code&gt; </p> <p> In order to use the pool allocators with multi_index_container and ease generic programming, I would suggest the following additions to pool_alloc.hpp: </p> <p> &lt;code&gt; </p> <blockquote> <p> template&lt; </p> <blockquote> <p> typename <a class="missing wiki">UserAllocator</a>, typename Mutex, unsigned <a class="missing wiki">NextSize</a>&gt; </p> </blockquote> <p> class pool_allocator&lt;void, <a class="missing wiki">UserAllocator</a>, Mutex, <a class="missing wiki">NextSize</a>&gt; { public: </p> <blockquote> <p> typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template &lt;class U&gt; struct rebind { </p> <blockquote> <p> typedef pool_allocator&lt;U, <a class="missing wiki">UserAllocator</a>, Mutex, <a class="missing wiki">NextSize</a>&gt; other; </p> </blockquote> <p> }; </p> </blockquote> <p> }; </p> </blockquote> <blockquote> <p> template&lt; </p> <blockquote> <p> typename <a class="missing wiki">UserAllocator</a>, typename Mutex, unsigned <a class="missing wiki">NextSize</a>&gt; </p> </blockquote> <p> class fast_pool_allocator&lt;void, <a class="missing wiki">UserAllocator</a>, Mutex, <a class="missing wiki">NextSize</a>&gt; { public: </p> <blockquote> <p> typedef void* pointer; typedef const void* const_pointer; typedef void value_type; template &lt;class U&gt; struct rebind { </p> <blockquote> <p> typedef fast_pool_allocator&lt;U, <a class="missing wiki">UserAllocator</a>, Mutex, <a class="missing wiki">NextSize</a>&gt; other; </p> </blockquote> <p> }; </p> </blockquote> <p> }; </p> </blockquote> <p> &lt;/code&gt; </p> <p> Best regards Armin Felke </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1996 Trac 1.4.3 Armin Felke Sat, 07 Jun 2008 16:31:08 GMT attachment set https://svn.boost.org/trac10/ticket/1996 https://svn.boost.org/trac10/ticket/1996 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">pool_alloc.txt</span> </li> </ul> <p> code (readable formatting) </p> Ticket Armin Felke Sat, 07 Jun 2008 16:32:09 GMT <link>https://svn.boost.org/trac10/ticket/1996#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1996#comment:1</guid> <description> <p> Sorry for screwing up the code formatting. If unreadable please see the attachment. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 26 Jun 2008 07:35:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/1996#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1996#comment:2</guid> <description> <p> It's useful. In my current project,I hope to use pool allocators for the boost function for optimizing,but I found the T can't be void. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Chris Newbold</dc:creator> <pubDate>Mon, 29 Sep 2008 19:35:00 GMT</pubDate> <title>owner, status, milestone changed https://svn.boost.org/trac10/ticket/1996#comment:3 https://svn.boost.org/trac10/ticket/1996#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">No-Maintainer</span> to <span class="trac-author">Chris Newbold</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.35.1</span> → <span class="trac-field-new">Boost 1.37.0</span> </li> </ul> Ticket Chris Newbold Mon, 29 Sep 2008 20:26:05 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1996#comment:4 https://svn.boost.org/trac10/ticket/1996#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed by changeset <a class="missing ticket">#49031</a> on trunk. </p> Ticket Chris Newbold Mon, 29 Sep 2008 20:27:42 GMT <link>https://svn.boost.org/trac10/ticket/1996#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1996#comment:5</guid> <description> <p> Argh; bad link. Make that <a class="changeset" href="https://svn.boost.org/trac10/changeset/49031/trunk" title="Address ticket #1996: &#34;void&#34; template specialization for pool allocators. ">[49031/trunk]</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>