]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/heap/detail/heap_node.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / heap / detail / heap_node.hpp
index c2eb011da8ff17893e5d12d7f21a713a9cda3658..8eb2541d67ae58fe309a4376299abd8928c37a23 100644 (file)
@@ -12,7 +12,7 @@
 #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
@@ -26,11 +26,10 @@ namespace heap   {
 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
@@ -99,21 +98,35 @@ template <typename Node,
           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;
     }
 
@@ -132,7 +145,12 @@ template <typename Node,
           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)
@@ -142,8 +160,13 @@ struct node_disposer
     {
         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_;