Boost C++ Libraries: Ticket #4277: Ease access to underlying singleton_pool https://svn.boost.org/trac10/ticket/4277 <p> It is not convenient to call <em>singleton_pool&lt;...&gt;::release_memory()</em> if you use <em>pool_allocator</em> or <em>fast_pool_allocator</em>. The reason is that the exact singleton_pool type has to be specified: </p> <pre class="wiki">typedef boost::pool_allocator&lt;int&gt; myAllocator; std::vector&lt;int, myAllocator&gt; v; ... //do something and empty v again boost::singleton_pool&lt;boost::pool_allocator_tag, sizeof(int)&gt;::release_memory(); </pre><p> In fact the call to <em>release_memory</em> might need even more template arguments (because of user allocators etc). And: The developer has to know all template parameters. If the vector declaration changes the call to <em>release_memory</em> has to be changed too, otherwise it would still compile but have no effect. This is error-prone. It would be much easier if <em>pool_allocator</em> and <em>fast_pool_allocator</em> would provide a typedef for the used singleton_pool. Then the above code would look like this: </p> <pre class="wiki">typedef boost::pool_allocator&lt;int&gt; myAllocator; std::vector&lt;int, myAllocator&gt; v; ... //do something and empty v again myAllocator::singleton_pool_type::release_memory(); </pre><p> The implementation in pool_alloc.hpp would look like this: </p> <pre class="wiki"> template &lt;typename T, typename UserAllocator, typename Mutex, unsigned NextSize&gt; class pool_allocator { public: typedef T value_type; typedef UserAllocator user_allocator; typedef Mutex mutex; ... typedef singleton_pool&lt;pool_allocator_tag, sizeof(T), UserAllocator, Mutex, NextSize&gt; singleton_pool_type; ... </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4277 Trac 1.4.3 Steven Watanabe Tue, 01 Jun 2010 16:28:54 GMT <link>https://svn.boost.org/trac10/ticket/4277#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4277#comment:1</guid> <description> <p> I hesitate to add such a typedef because it isn't reliable. </p> <pre class="wiki">{ std::list&lt;int, boost::pool_allocator&lt;int&gt; &gt; l; ... } boost::pool_allocator&lt;int&gt;::singleton_pool_type::release_memory(); // no effect </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Fri, 07 Jan 2011 11:25:14 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/4277#comment:2 https://svn.boost.org/trac10/ticket/4277#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">boostpool@…</span> added </li> </ul> Ticket John Maddock Thu, 03 Mar 2011 18:27:53 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4277#comment:3 https://svn.boost.org/trac10/ticket/4277#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">wontfix</span> </li> </ul> <p> I agree with Steven - the actual type of the allocator used by a container is "unmentionable" - and indeed more than one such type may even be used. </p> <p> Closing as won't fix. </p> Ticket