diff DEPENDENCIES/generic/include/boost/intrusive/treap.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/intrusive/treap.hpp	Fri Sep 04 12:01:02 2015 +0100
+++ b/DEPENDENCIES/generic/include/boost/intrusive/treap.hpp	Mon Sep 07 11:12:49 2015 +0100
@@ -13,28 +13,33 @@
 #define BOOST_INTRUSIVE_TREAP_HPP
 
 #include <boost/intrusive/detail/config_begin.hpp>
-#include <algorithm>
-#include <cstddef>
-#include <functional>
-#include <iterator>
-#include <utility>
+#include <boost/intrusive/intrusive_fwd.hpp>
 
 #include <boost/intrusive/detail/assert.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/intrusive/intrusive_fwd.hpp>
 #include <boost/intrusive/bs_set_hook.hpp>
 #include <boost/intrusive/bstree.hpp>
 #include <boost/intrusive/detail/tree_node.hpp>
 #include <boost/intrusive/detail/ebo_functor_holder.hpp>
 #include <boost/intrusive/pointer_traits.hpp>
-#include <boost/intrusive/detail/utilities.hpp>
-#include <boost/intrusive/pointer_traits.hpp>
-#include <boost/intrusive/options.hpp>
+#include <boost/intrusive/detail/get_value_traits.hpp>
 #include <boost/intrusive/detail/mpl.hpp>
 #include <boost/intrusive/treap_algorithms.hpp>
 #include <boost/intrusive/link_mode.hpp>
-#include <boost/move/move.hpp>
 #include <boost/intrusive/priority_compare.hpp>
+#include <boost/intrusive/detail/node_cloner_disposer.hpp>
+#include <boost/intrusive/detail/key_nodeptr_comp.hpp>
+
+#include <boost/static_assert.hpp>
+#include <boost/move/utility_core.hpp>
+#include <boost/move/adl_move_swap.hpp>
+
+#include <cstddef>
+#include <boost/intrusive/detail/minimal_less_equal_header.hpp>
+#include <boost/intrusive/detail/minimal_pair_header.hpp>   //std::pair
+
+#if defined(BOOST_HAS_PRAGMA_ONCE)
+#  pragma once
+#endif
 
 namespace boost {
 namespace intrusive {
@@ -43,11 +48,12 @@
 
 struct treap_defaults
 {
-   typedef detail::default_bstree_hook proto_value_traits;
+   typedef default_bstree_hook_applier proto_value_traits;
    static const bool constant_time_size = true;
    typedef std::size_t size_type;
    typedef void compare;
    typedef void priority;
+   typedef void header_holder_type;
 };
 
 /// @endcond
@@ -68,16 +74,17 @@
 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
 template<class T, class ...Options>
 #else
-template<class ValueTraits, class VoidOrKeyComp, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize>
+template<class ValueTraits, class VoidOrKeyComp, class VoidOrPrioComp, class SizeType, bool ConstantTimeSize, typename HeaderHolder>
 #endif
 class treap_impl
    /// @cond
-   :  public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms>
-   ,  public detail::ebo_functor_holder
+   : public bstree_impl<ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms, HeaderHolder>
+   //Use public inheritance to avoid MSVC bugs with closures
+   , public detail::ebo_functor_holder
          < typename get_prio
             < VoidOrPrioComp
             , typename bstree_impl
-               <ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms>::value_type>::type 
+               <ValueTraits, VoidOrKeyComp, SizeType, ConstantTimeSize, BsTreeAlgorithms, HeaderHolder>::value_type>::type
          >
    /// @endcond
 {
@@ -85,9 +92,9 @@
    typedef ValueTraits                                               value_traits;
    /// @cond
    typedef bstree_impl< ValueTraits, VoidOrKeyComp, SizeType
-                      , ConstantTimeSize, BsTreeAlgorithms>          tree_type;
+                      , ConstantTimeSize, BsTreeAlgorithms
+                      , HeaderHolder>                                tree_type;
    typedef tree_type                                                 implementation_defined;
-   typedef typename tree_type::real_value_traits                     real_value_traits;
    typedef get_prio
                < VoidOrPrioComp
                , typename tree_type::value_type>                     get_prio_type;
@@ -120,7 +127,7 @@
 
    static const bool constant_time_size      = implementation_defined::constant_time_size;
    static const bool stateful_value_traits   = implementation_defined::stateful_value_traits;
-   static const bool safemode_or_autounlink = is_safe_autounlink<real_value_traits::link_mode>::value;
+   static const bool safemode_or_autounlink = is_safe_autounlink<value_traits::link_mode>::value;
 
    /// @cond
    private:
@@ -180,7 +187,7 @@
 
    //! @copydoc ::boost::intrusive::bstree::bstree(bstree &&)
    treap_impl(BOOST_RV_REF(treap_impl) x)
-      : tree_type(::boost::move(static_cast<tree_type&>(x)))
+      : tree_type(BOOST_MOVE_BASE(tree_type, x))
       , prio_base(::boost::move(x.priv_pcomp()))
    {}
 
@@ -217,7 +224,7 @@
    //!
    //! <b>Throws</b>: Nothing.
    iterator top()
-   {  return this->empty() ? this->end() : iterator(node_traits::get_parent(this->tree_type::header_ptr()), this);   }
+   {  return this->tree_type::root();   }
 
    //! <b>Effects</b>: Returns a const_iterator pointing to the highest priority object of the treap..
    //!
@@ -233,7 +240,7 @@
    //!
    //! <b>Throws</b>: Nothing.
    const_iterator ctop() const
-   {  return this->empty() ? this->cend() : const_iterator(node_traits::get_parent(this->tree_type::header_ptr()), this);   }
+   {  return this->tree_type::root();   }
 
    #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
    //! @copydoc ::boost::intrusive::bstree::rbegin()
@@ -325,8 +332,7 @@
    {
       tree_type::swap(other);
       //This can throw
-      using std::swap;
-      swap(this->priv_pcomp(), other.priv_pcomp());
+      ::boost::adl_move_swap(this->priv_pcomp(), other.priv_pcomp());
    }
 
    //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
@@ -363,15 +369,15 @@
    //!   No copy-constructors are called.
    iterator insert_equal(reference value)
    {
-      detail::key_nodeptr_comp<value_compare, real_value_traits>
-         key_node_comp(this->value_comp(), &this->get_real_value_traits());
-      detail::key_nodeptr_comp<priority_compare, real_value_traits>
-         key_node_pcomp(this->priv_pcomp(), &this->get_real_value_traits());
-      node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+      detail::key_nodeptr_comp<value_compare, value_traits>
+         key_node_comp(this->value_comp(), &this->get_value_traits());
+      detail::key_nodeptr_comp<priority_compare, value_traits>
+         key_node_pcomp(this->priv_pcomp(), &this->get_value_traits());
+      node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
       if(safemode_or_autounlink)
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
       iterator ret(node_algorithms::insert_equal_upper_bound
-         (this->tree_type::header_ptr(), to_insert, key_node_comp, key_node_pcomp), this->real_value_traits_ptr());
+         (this->tree_type::header_ptr(), to_insert, key_node_comp, key_node_pcomp), this->priv_value_traits_ptr());
       this->tree_type::sz_traits().increment();
       return ret;
    }
@@ -392,15 +398,15 @@
    //!   No copy-constructors are called.
    iterator insert_equal(const_iterator hint, reference value)
    {
-      detail::key_nodeptr_comp<value_compare, real_value_traits>
-         key_node_comp(this->value_comp(), &this->get_real_value_traits());
-      detail::key_nodeptr_comp<priority_compare, real_value_traits>
-         key_node_pcomp(this->priv_pcomp(), &this->get_real_value_traits());
-      node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+      detail::key_nodeptr_comp<value_compare, value_traits>
+         key_node_comp(this->value_comp(), &this->get_value_traits());
+      detail::key_nodeptr_comp<priority_compare, value_traits>
+         key_node_pcomp(this->priv_pcomp(), &this->get_value_traits());
+      node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
       if(safemode_or_autounlink)
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
       iterator ret (node_algorithms::insert_equal
-         (this->tree_type::header_ptr(), hint.pointed_node(), to_insert, key_node_comp, key_node_pcomp), this->real_value_traits_ptr());
+         (this->tree_type::header_ptr(), hint.pointed_node(), to_insert, key_node_comp, key_node_pcomp), this->priv_value_traits_ptr());
       this->tree_type::sz_traits().increment();
       return ret;
    }
@@ -540,14 +546,14 @@
       ( const KeyType &key, KeyValueCompare key_value_comp
       , KeyValuePrioCompare key_value_pcomp, insert_commit_data &commit_data)
    {
-      detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
-         ocomp(key_value_comp, &this->get_real_value_traits());
-      detail::key_nodeptr_comp<KeyValuePrioCompare, real_value_traits>
-         pcomp(key_value_pcomp, &this->get_real_value_traits());
+      detail::key_nodeptr_comp<KeyValueCompare, value_traits>
+         ocomp(key_value_comp, &this->get_value_traits());
+      detail::key_nodeptr_comp<KeyValuePrioCompare, value_traits>
+         pcomp(key_value_pcomp, &this->get_value_traits());
       std::pair<node_ptr, bool> ret =
          (node_algorithms::insert_unique_check
             (this->tree_type::header_ptr(), key, ocomp, pcomp, commit_data));
-      return std::pair<iterator, bool>(iterator(ret.first, this->real_value_traits_ptr()), ret.second);
+      return std::pair<iterator, bool>(iterator(ret.first, this->priv_value_traits_ptr()), ret.second);
    }
 
    //! <b>Requires</b>: key_value_comp must be a comparison function that induces
@@ -592,14 +598,14 @@
       , KeyValuePrioCompare key_value_pcomp
       , insert_commit_data &commit_data)
    {
-      detail::key_nodeptr_comp<KeyValueCompare, real_value_traits>
-         ocomp(key_value_comp, &this->get_real_value_traits());
-      detail::key_nodeptr_comp<KeyValuePrioCompare, real_value_traits>
-         pcomp(key_value_pcomp, &this->get_real_value_traits());
+      detail::key_nodeptr_comp<KeyValueCompare, value_traits>
+         ocomp(key_value_comp, &this->get_value_traits());
+      detail::key_nodeptr_comp<KeyValuePrioCompare, value_traits>
+         pcomp(key_value_pcomp, &this->get_value_traits());
       std::pair<node_ptr, bool> ret =
          (node_algorithms::insert_unique_check
             (this->tree_type::header_ptr(), hint.pointed_node(), key, ocomp, pcomp, commit_data));
-      return std::pair<iterator, bool>(iterator(ret.first, this->real_value_traits_ptr()), ret.second);
+      return std::pair<iterator, bool>(iterator(ret.first, this->priv_value_traits_ptr()), ret.second);
    }
 
    //! <b>Requires</b>: value must be an lvalue of type value_type. commit_data
@@ -621,12 +627,12 @@
    //!   erased between the "insert_check" and "insert_commit" calls.
    iterator insert_unique_commit(reference value, const insert_commit_data &commit_data)
    {
-      node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+      node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
       if(safemode_or_autounlink)
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
       node_algorithms::insert_unique_commit(this->tree_type::header_ptr(), to_insert, commit_data);
       this->tree_type::sz_traits().increment();
-      return iterator(to_insert, this->real_value_traits_ptr());
+      return iterator(to_insert, this->priv_value_traits_ptr());
    }
 
    //! <b>Requires</b>: value must be an lvalue, "pos" must be
@@ -645,13 +651,13 @@
    //! by advanced users.
    iterator insert_before(const_iterator pos, reference value)
    {
-      node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+      node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
       if(safemode_or_autounlink)
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
-      detail::key_nodeptr_comp<priority_compare, real_value_traits>
-         pcomp(this->priv_pcomp(), &this->get_real_value_traits());
+      detail::key_nodeptr_comp<priority_compare, value_traits>
+         pcomp(this->priv_pcomp(), &this->get_value_traits());
       iterator ret (node_algorithms::insert_before
-         (this->tree_type::header_ptr(), pos.pointed_node(), to_insert, pcomp), this->real_value_traits_ptr());
+         (this->tree_type::header_ptr(), pos.pointed_node(), to_insert, pcomp), this->priv_value_traits_ptr());
       this->tree_type::sz_traits().increment();
       return ret;
    }
@@ -672,11 +678,11 @@
    //!   by advanced users.
    void push_back(reference value)
    {
-      node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+      node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
       if(safemode_or_autounlink)
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
-      detail::key_nodeptr_comp<priority_compare, real_value_traits>
-         pcomp(this->priv_pcomp(), &this->get_real_value_traits());
+      detail::key_nodeptr_comp<priority_compare, value_traits>
+         pcomp(this->priv_pcomp(), &this->get_value_traits());
       node_algorithms::push_back(this->tree_type::header_ptr(), to_insert, pcomp);
       this->tree_type::sz_traits().increment();
    }
@@ -697,16 +703,16 @@
    //!   by advanced users.
    void push_front(reference value)
    {
-      node_ptr to_insert(this->get_real_value_traits().to_node_ptr(value));
+      node_ptr to_insert(this->get_value_traits().to_node_ptr(value));
       if(safemode_or_autounlink)
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(node_algorithms::unique(to_insert));
-      detail::key_nodeptr_comp<priority_compare, real_value_traits>
-         pcomp(this->priv_pcomp(), &this->get_real_value_traits());
+      detail::key_nodeptr_comp<priority_compare, value_traits>
+         pcomp(this->priv_pcomp(), &this->get_value_traits());
       node_algorithms::push_front(this->tree_type::header_ptr(), to_insert, pcomp);
       this->tree_type::sz_traits().increment();
    }
 
-   //! <b>Effects</b>: Erases the element pointed to by pos.
+   //! <b>Effects</b>: Erases the element pointed to by i.
    //!
    //! <b>Complexity</b>: Average complexity for erase element is constant time.
    //!
@@ -721,8 +727,8 @@
       node_ptr to_erase(i.pointed_node());
       if(safemode_or_autounlink)
          BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!node_algorithms::unique(to_erase));
-      detail::key_nodeptr_comp<priority_compare, real_value_traits>
-         key_node_pcomp(this->priv_pcomp(), &this->get_real_value_traits());
+      detail::key_nodeptr_comp<priority_compare, value_traits>
+         key_node_pcomp(this->priv_pcomp(), &this->get_value_traits());
       node_algorithms::erase(this->tree_type::header_ptr(), to_erase, key_node_pcomp);
       this->tree_type::sz_traits().decrement();
       if(safemode_or_autounlink)
@@ -782,7 +788,7 @@
 
    //! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
    //!
-   //! <b>Effects</b>: Erases the element pointed to by pos.
+   //! <b>Effects</b>: Erases the element pointed to by i.
    //!   Disposer::operator()(pointer) is called for the removed element.
    //!
    //! <b>Complexity</b>: Average complexity for erase element is constant time.
@@ -796,7 +802,7 @@
    {
       node_ptr to_erase(i.pointed_node());
       iterator ret(this->erase(i));
-      disposer(this->get_real_value_traits().to_value_ptr(to_erase));
+      disposer(this->get_value_traits().to_value_ptr(to_erase));
       return ret;
    }
 
@@ -898,11 +904,24 @@
    void clear_and_dispose(Disposer disposer)
    {
       node_algorithms::clear_and_dispose(this->tree_type::header_ptr()
-         , detail::node_disposer<Disposer, real_value_traits, TreapAlgorithms>(disposer, &this->get_real_value_traits()));
+         , detail::node_disposer<Disposer, value_traits, TreapAlgorithms>(disposer, &this->get_value_traits()));
       node_algorithms::init_header(this->tree_type::header_ptr());
       this->tree_type::sz_traits().set_size(0);
    }
 
+   //! @copydoc ::boost::intrusive::bstree::check(ExtraChecker)const
+   template <class ExtraChecker>
+   void check(ExtraChecker extra_checker) const
+   {
+      typedef detail::key_nodeptr_comp<priority_compare, value_traits> nodeptr_prio_comp_t;
+      nodeptr_prio_comp_t nodeptr_prio_comp(priv_pcomp(), &this->get_value_traits());
+      tree_type::check(detail::treap_node_extra_checker<ValueTraits, nodeptr_prio_comp_t, ExtraChecker>(nodeptr_prio_comp, extra_checker));
+   }
+
+   //! @copydoc ::boost::intrusive::bstree::check()const
+   void check() const
+   {  check(detail::empty_node_checker<ValueTraits>());  }
+
    #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
    //! @copydoc ::boost::intrusive::bstree::count(const_reference)const
    size_type count(const_reference value) const;
@@ -910,10 +929,10 @@
    //! @copydoc ::boost::intrusive::bstree::count(const KeyType&,KeyValueCompare)const
    template<class KeyType, class KeyValueCompare>
    size_type count(const KeyType& key, KeyValueCompare comp) const;
-   
+
    //! @copydoc ::boost::intrusive::bstree::lower_bound(const_reference)
    iterator lower_bound(const_reference value);
-   
+
    //! @copydoc ::boost::intrusive::bstree::lower_bound(const KeyType&,KeyValueCompare)
    template<class KeyType, class KeyValueCompare>
    iterator lower_bound(const KeyType& key, KeyValueCompare comp);
@@ -1063,14 +1082,15 @@
 template<class T, class ...Options>
 #else
 template<class T, class O1 = void, class O2 = void
-                , class O3 = void, class O4 = void>
+                , class O3 = void, class O4 = void
+                , class O5 = void>
 #endif
 struct make_treap
 {
    typedef typename pack_options
       < treap_defaults,
       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
-      O1, O2, O3, O4
+      O1, O2, O3, O4, O5
       #else
       Options...
       #endif
@@ -1085,6 +1105,7 @@
          , typename packed_options::priority
          , typename packed_options::size_type
          , packed_options::constant_time_size
+         , typename packed_options::header_holder_type
          > implementation_defined;
    /// @endcond
    typedef implementation_defined type;
@@ -1093,14 +1114,14 @@
 #ifndef BOOST_INTRUSIVE_DOXYGEN_INVOKED
 
 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
-template<class T, class O1, class O2, class O3, class O4>
+template<class T, class O1, class O2, class O3, class O4, class O5>
 #else
 template<class T, class ...Options>
 #endif
 class treap
    :  public make_treap<T,
       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
-      O1, O2, O3, O4
+      O1, O2, O3, O4, O5
       #else
       Options...
       #endif
@@ -1109,7 +1130,7 @@
    typedef typename make_treap
       <T,
       #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
-      O1, O2, O3, O4
+      O1, O2, O3, O4, O5
       #else
       Options...
       #endif
@@ -1120,14 +1141,13 @@
    typedef typename Base::value_compare      value_compare;
    typedef typename Base::priority_compare   priority_compare;
    typedef typename Base::value_traits       value_traits;
-   typedef typename Base::real_value_traits  real_value_traits;
    typedef typename Base::iterator           iterator;
    typedef typename Base::const_iterator     const_iterator;
    typedef typename Base::reverse_iterator           reverse_iterator;
    typedef typename Base::const_reverse_iterator     const_reverse_iterator;
 
    //Assert if passed value traits are compatible with the type
-   BOOST_STATIC_ASSERT((detail::is_same<typename real_value_traits::value_type, T>::value));
+   BOOST_STATIC_ASSERT((detail::is_same<typename value_traits::value_type, T>::value));
 
    explicit treap( const value_compare &cmp = value_compare()
                  , const priority_compare &pcmp = priority_compare()
@@ -1144,11 +1164,11 @@
    {}
 
    treap(BOOST_RV_REF(treap) x)
-      :  Base(::boost::move(static_cast<Base&>(x)))
+      :  Base(BOOST_MOVE_BASE(Base, x))
    {}
 
    treap& operator=(BOOST_RV_REF(treap) x)
-   {  return static_cast<treap&>(this->Base::operator=(::boost::move(static_cast<Base&>(x))));  }
+   {  return static_cast<treap&>(this->Base::operator=(BOOST_MOVE_BASE(Base, x)));  }
 
    static treap &container_from_end_iterator(iterator end_iterator)
    {  return static_cast<treap &>(Base::container_from_end_iterator(end_iterator));   }