Boost C++ Libraries: Ticket #9328: Error initializing a boost:container's allocator with a reference. https://svn.boost.org/trac10/ticket/9328 <p> Consider the following: </p> <p> struct arena; </p> <p> struct A : std::allocator&lt;int&gt; { </p> <blockquote> <p> A(arena {} A(arena*) {} </p> </blockquote> <p> }; </p> <p> typedef boost::container::vector&lt;int,boost::container::scoped_allocator_adaptor&lt;A&gt; &gt; avector; </p> <p> void foo(arena a) { </p> <blockquote> <p> avector v1(a); <em> error: can't bind a mutable &amp; to a const&amp; avector v2(&amp;a); </em> fine avector v3(A(a)); <em> fine avector v3(A(&amp;a)); </em> fine </p> </blockquote> <p> } </p> <p> The initialization of v1 generates the following compilation error (under GCC 4.4.7): </p> <p> /opt/scidb/13.9/3rdparty/boost/include/boost/container/scoped_allocator.hpp: In constructor ‘boost::container::container_detail::scoped_allocator_adaptor_base&lt;<a class="missing wiki">OuterAlloc</a>, true, boost::container::container_detail::nat, boost::container::container_detail::nat, boost::container::container_detail::nat, boost::container::container_detail::nat, boost::container::container_detail::nat, boost::container::container_detail::nat, boost::container::container_detail::nat, boost::container::container_detail::nat, boost::container::container_detail::nat, boost::container::container_detail::nat&gt;::scoped_allocator_adaptor_base(const OuterA2&amp;) [with OuterA2 = ARENA, <a class="missing wiki">OuterAlloc</a> = A]’: /opt/scidb/13.9/3rdparty/boost/include/boost/preprocessor/iteration/detail/local.hpp:34: instantiated from ‘boost::container::scoped_allocator_adaptor&lt;<a class="missing wiki">OuterAlloc</a>, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9&gt;::scoped_allocator_adaptor(const OuterA2&amp;) [with OuterA2 = ARENA, <a class="missing wiki">OuterAlloc</a> = A, Q0 = boost::container::container_detail::nat, Q1 = boost::container::container_detail::nat, Q2 = boost::container::container_detail::nat, Q3 = boost::container::container_detail::nat, Q4 = boost::container::container_detail::nat, Q5 = boost::container::container_detail::nat, Q6 = boost::container::container_detail::nat, Q7 = boost::container::container_detail::nat, Q8 = boost::container::container_detail::nat, Q9 = boost::container::container_detail::nat]’ /local/mem/src/tests/unit/ArenaUnitTests.h:743: instantiated from here /opt/scidb/13.9/3rdparty/boost/include/boost/container/scoped_allocator.hpp:890: error: no matching function for call to ‘A::A(const ARENA&amp;)’ /local/mem/src/tests/unit/ArenaUnitTests.h:736: note: candidates are: A::A(ARENA*) /local/mem/src/tests/unit/ArenaUnitTests.h:735: note: A::A(ARENA&amp;) /local/mem/src/tests/unit/ArenaUnitTests.h:734: note: A::A(const A&amp;) </p> <p> Notice that the implementation of scoped_allocator_adaptor is attempting to initialize the adaptor with a *const* reference to an ARENA when a mutable reference was in fact supplied to the container's constructor. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9328 Trac 1.4.3 anonymous Wed, 30 Oct 2013 22:18:24 GMT component changed; owner set https://svn.boost.org/trac10/ticket/9328#comment:1 https://svn.boost.org/trac10/ticket/9328#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Ion Gaztañaga</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">container</span> </li> </ul> Ticket Ion Gaztañaga Thu, 31 Oct 2013 11:59:39 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9328#comment:2 https://svn.boost.org/trac10/ticket/9328#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">wontfix</span> </li> </ul> <p> It's a limitation of Boost.Move. It only accepts const references or rvalue references for constructor forwarding. Otherwise it would need thousands of overloads for a dozen of arguments. It's a pain but supporting move semantics also for allocator was considered more important than this annoyance. </p> Ticket