Boost C++ Libraries: Ticket #7357: copy constructor of mutable_heap does not copy Compare base class https://svn.boost.org/trac10/ticket/7357 <p> The copy constructor of priority_queue_mutable_wrapper only copies over the elements in the queue and it default constructs the Compare base class. </p> <p> Therefore the third assertion in the code below fails. This is a severe problem when an indirect comparison is applied. </p> <p> #include &lt;boost/heap/d_ary_heap.hpp&gt; #include &lt;assert.h&gt; struct multiplied_compare { </p> <blockquote> <p> multiplied_compare(int m = 1) : m(m) {} </p> </blockquote> <blockquote> <p> bool operator()(const int&amp; a, const int&amp; b) const { </p> <blockquote> <p> return m*a &lt; m*b; </p> </blockquote> <p> } int m; </p> </blockquote> <p> }; </p> <p> int main() { </p> <blockquote> <p> typedef boost::heap::d_ary_heap&lt; </p> <blockquote> <p> int, boost::heap::mutable_&lt;true&gt;, boost::heap::compare&lt;multiplied_compare&gt;, boost::heap::arity&lt;4&gt; &gt; heap_type; </p> </blockquote> </blockquote> <p> </p> <blockquote> <p> heap_type plus(1); plus.push(100); plus.push(200); assert(plus.top() == 200); </p> </blockquote> <blockquote> <p> heap_type minus(-1); minus.push(100); minus.push(200); assert(minus.top() == 100); </p> </blockquote> <blockquote> <p> heap_type copy = minus; copy.clear(); copy.push(100); copy.push(200); assert(copy.top() == 100); </p> </blockquote> <blockquote> <p> return 0; </p> </blockquote> <p> } </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7357 Trac 1.4.3 timblechmann Mon, 10 Sep 2012 14:58:25 GMT <link>https://svn.boost.org/trac10/ticket/7357#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7357#comment:1</guid> <description> <p> thanks for reporting. fixed in trunk </p> </description> <category>Ticket</category> </item> <item> <dc:creator>timblechmann</dc:creator> <pubDate>Thu, 22 Nov 2012 11:51:59 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7357#comment:2 https://svn.boost.org/trac10/ticket/7357#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> Ticket