Boost logo

Boost Users :

Subject: Re: [Boost-users] [1.54.0] Beta 1 Available
From: Cromwell Enage (sponage_at_[hidden])
Date: 2013-06-06 13:10:55


Hi, all. When calling the merge() member function of a boost::heap::d_ary_heap, is the heap passed in not supposed to be emptied? Here's my test program: ['' #include <boost/heap/d_ary_heap.hpp> #include <boost/heap/binomial_heap.hpp> #include <boost/heap/fibonacci_heap.hpp> #include <boost/heap/pairing_heap.hpp> #include <boost/heap/skew_heap.hpp> #include <boost/test/minimal.hpp> template <typename Heap> void test_heap_merge_memfun() {     Heap heap_1, heap_2;     heap_1.push(3);     heap_1.push(5);     heap_1.push(1);     heap_2.push(2);     heap_2.push(4);     heap_2.push(0);     heap_1.merge(heap_2);     std::cout << " heap_2";     if (!heap_2.empty())     {         BOOST_CHECK(4 == heap_2.top());         heap_2.pop();         BOOST_CHECK(2 == heap_2.top());         heap_2.pop();         BOOST_CHECK(0 == heap_2.top());         heap_2.pop();         std::cout << " not";     }     std::cout << " emptied." << std::endl;     BOOST_CHECK(heap_2.empty());     BOOST_CHECK(5 == heap_1.top());     heap_1.pop();     BOOST_CHECK(4 == heap_1.top());     heap_1.pop();     BOOST_CHECK(3 == heap_1.top());     heap_1.pop();     BOOST_CHECK(2 == heap_1.top());     heap_1.pop();     BOOST_CHECK(1 == heap_1.top());     heap_1.pop();     BOOST_CHECK(0 == heap_1.top());     heap_1.pop();     BOOST_CHECK(heap_1.empty()); } int test_main(int argc, char** argv) {     test_heap_merge_memfun<         boost::heap::d_ary_heap<             int           , boost::heap::arity<4>           , boost::heap::mutable_<true>         >     >();     test_heap_merge_memfun<boost::heap::binomial_heap<int> >();     test_heap_merge_memfun<boost::heap::fibonacci_heap<int> >();     test_heap_merge_memfun<boost::heap::pairing_heap<int> >();     test_heap_merge_memfun<         boost::heap::skew_heap<int,boost::heap::mutable_<true> >     >();     return 0; } ''] When I run this program, I see that all the other heap types empty the heap passed in. I use gcc 4.2.1 with Apple clang version 4.0 on MacOSX 10.8 Cromwell D. Enage



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net