#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/intrusive/list.hpp>
-#include <boost/mpl/if.hpp>
+#include <boost/type_traits/conditional.hpp>
#ifdef BOOST_HEAP_SANITYCHECKS
#define BOOST_HEAP_ASSERT BOOST_ASSERT
namespace detail {
namespace bi = boost::intrusive;
-namespace mpl = boost::mpl;
template <bool auto_unlink = false>
struct heap_node_base:
- bi::list_base_hook<typename mpl::if_c<auto_unlink,
+ bi::list_base_hook<typename boost::conditional<auto_unlink,
bi::link_mode<bi::auto_unlink>,
bi::link_mode<bi::safe_link>
>::type
typename Alloc>
struct node_cloner
{
+#ifndef BOOST_NO_CXX11_ALLOCATOR
+ typedef std::allocator_traits<Alloc> allocator_traits;
+#endif
+
node_cloner(Alloc & allocator):
allocator(allocator)
{}
Node * operator() (NodeBase const & node)
{
+#ifdef BOOST_NO_CXX11_ALLOCATOR
Node * ret = allocator.allocate(1);
new (ret) Node(static_cast<Node const &>(node), allocator);
+#else
+ Node * ret = allocator_traits::allocate(allocator, 1);
+ allocator_traits::construct(allocator, ret, static_cast<Node const &>(node), allocator);
+#endif
return ret;
}
Node * operator() (NodeBase const & node, Node * parent)
{
+#ifdef BOOST_NO_CXX11_ALLOCATOR
Node * ret = allocator.allocate(1);
new (ret) Node(static_cast<Node const &>(node), allocator, parent);
+#else
+ Node * ret = allocator_traits::allocate(allocator, 1);
+ allocator_traits::construct(allocator, ret, static_cast<Node const &>(node), allocator, parent);
+#endif
return ret;
}
typename Alloc>
struct node_disposer
{
+#ifdef BOOST_NO_CXX11_ALLOCATOR
typedef typename Alloc::pointer node_pointer;
+#else
+ typedef std::allocator_traits<Alloc> allocator_traits;
+ typedef typename allocator_traits::pointer node_pointer;
+#endif
node_disposer(Alloc & alloc):
alloc_(alloc)
{
node_pointer n = static_cast<node_pointer>(base);
n->clear_subtree(alloc_);
+#ifdef BOOST_NO_CXX11_ALLOCATOR
alloc_.destroy(n);
alloc_.deallocate(n, 1);
+#else
+ allocator_traits::destroy(alloc_, n);
+ allocator_traits::deallocate(alloc_, n, 1);
+#endif
}
Alloc & alloc_;