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