Boost C++ Libraries: Ticket #11208: Swapping allocators does not use ADL https://svn.boost.org/trac10/ticket/11208 <p> boost::circular buffer has issues when using it with Boost.Interprocess, due to attempting to use std::swap on the allocators. Specifically: </p> <div class="wiki-code"><div class="code"><pre><span class="kt">void</span> <span class="nf">swap_allocator</span><span class="p">(</span><span class="n">circular_buffer</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span> <span class="n">Alloc</span><span class="o">&gt;&amp;</span> <span class="n">cb</span><span class="p">,</span> <span class="k">const</span> <span class="n">false_type</span><span class="o">&amp;</span><span class="p">)</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">swap</span><span class="p">(</span><span class="n">m_alloc</span><span class="p">,</span> <span class="n">cb</span><span class="p">.</span><span class="n">m_alloc</span><span class="p">);</span> <span class="p">}</span> </pre></div></div><p> does not allow ADL to find the correct swap implementation. This can be worked around by specializing std::swap, but this is not ideal, and leads to some compile issues on OSX with Clang. </p> <p> The correct implementation would look like </p> <div class="wiki-code"><div class="code"><pre><span class="kt">void</span> <span class="nf">swap_allocator</span><span class="p">(</span><span class="n">circular_buffer</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span> <span class="n">Alloc</span><span class="o">&gt;&amp;</span> <span class="n">cb</span><span class="p">,</span> <span class="k">const</span> <span class="n">false_type</span><span class="o">&amp;</span><span class="p">)</span> <span class="p">{</span> <span class="k">using</span> <span class="n">std</span><span class="o">::</span><span class="n">swap</span><span class="p">;</span> <span class="n">swap</span><span class="p">(</span><span class="n">m_alloc</span><span class="p">,</span> <span class="n">cb</span><span class="p">.</span><span class="n">m_alloc</span><span class="p">);</span> <span class="p">}</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11208 Trac 1.4.3 Jan Gaspar Wed, 22 Apr 2015 21:49:23 GMT <link>https://svn.boost.org/trac10/ticket/11208#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11208#comment:1</guid> <description> <p> Please apply the patch. The library is not maintained be me any more. </p> </description> <category>Ticket</category> </item> <item> <author>Alex Merry <alexander.merry@…></author> <pubDate>Thu, 28 May 2015 10:25:02 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/11208#comment:2 https://svn.boost.org/trac10/ticket/11208#comment:2 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.59.0</span> </li> </ul> <p> See <a class="ext-link" href="https://github.com/boostorg/circular_buffer/pull/7"><span class="icon">​</span>https://github.com/boostorg/circular_buffer/pull/7</a> </p> <p> This should be resolved in 1.59.0. </p> Ticket