|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65042 - in branches/release/boost/intrusive: . detail
From: igaztanaga_at_[hidden]
Date: 2010-08-26 17:51:16
Author: igaztanaga
Date: 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
New Revision: 65042
URL: http://svn.boost.org/trac/boost/changeset/65042
Log:
Fixes for Boost 1.45
Added:
branches/release/boost/intrusive/parent_from_member.hpp (contents, props changed)
Text files modified:
branches/release/boost/intrusive/avl_set.hpp | 4 +
branches/release/boost/intrusive/avltree_algorithms.hpp | 2
branches/release/boost/intrusive/circular_slist_algorithms.hpp | 2
branches/release/boost/intrusive/derivation_value_traits.hpp | 15 ++++
branches/release/boost/intrusive/detail/any_node_and_algorithms.hpp | 6 +
branches/release/boost/intrusive/detail/hashtable_node.hpp | 18 +++-
branches/release/boost/intrusive/detail/list_node.hpp | 24 +++----
branches/release/boost/intrusive/detail/parent_from_member.hpp | 12 +--
branches/release/boost/intrusive/detail/slist_node.hpp | 24 +++----
branches/release/boost/intrusive/detail/tree_algorithms.hpp | 6 +
branches/release/boost/intrusive/detail/tree_node.hpp | 25 +++----
branches/release/boost/intrusive/detail/utilities.hpp | 130 +++++++++++++++++++++++++++++++++++----
branches/release/boost/intrusive/hashtable.hpp | 61 +++++++++---------
branches/release/boost/intrusive/intrusive_fwd.hpp | 83 ++++++++++++++-----------
branches/release/boost/intrusive/list.hpp | 27 ++++++-
branches/release/boost/intrusive/options.hpp | 18 +++++
branches/release/boost/intrusive/rbtree.hpp | 27 ++++++--
branches/release/boost/intrusive/rbtree_algorithms.hpp | 3
branches/release/boost/intrusive/set.hpp | 23 ++++++
branches/release/boost/intrusive/sgtree_algorithms.hpp | 2
branches/release/boost/intrusive/splay_set.hpp | 4 +
branches/release/boost/intrusive/splaytree.hpp | 4
branches/release/boost/intrusive/splaytree_algorithms.hpp | 2
branches/release/boost/intrusive/treap.hpp | 6
branches/release/boost/intrusive/treap_algorithms.hpp | 2
branches/release/boost/intrusive/treap_set.hpp | 4 +
branches/release/boost/intrusive/unordered_set.hpp | 40 ++++++------
branches/release/boost/intrusive/unordered_set_hook.hpp | 8 ++
28 files changed, 392 insertions(+), 190 deletions(-)
Modified: branches/release/boost/intrusive/avl_set.hpp
==============================================================================
--- branches/release/boost/intrusive/avl_set.hpp (original)
+++ branches/release/boost/intrusive/avl_set.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -74,6 +74,8 @@
typedef typename implementation_defined::const_node_ptr const_node_ptr;
typedef typename implementation_defined::node_algorithms node_algorithms;
+ static const bool constant_time_size = Config::constant_time_size;
+
/// @cond
private:
tree_type tree_;
@@ -1264,6 +1266,8 @@
typedef typename implementation_defined::const_node_ptr const_node_ptr;
typedef typename implementation_defined::node_algorithms node_algorithms;
+ static const bool constant_time_size = Config::constant_time_size;
+
/// @cond
private:
tree_type tree_;
Modified: branches/release/boost/intrusive/avltree_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/avltree_algorithms.hpp (original)
+++ branches/release/boost/intrusive/avltree_algorithms.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -104,7 +104,7 @@
static node_ptr uncast(const_node_ptr ptr)
{
- return node_ptr(const_cast<node*>(::boost::intrusive::detail::get_pointer(ptr)));
+ return node_ptr(const_cast<node*>(::boost::intrusive::detail::boost_intrusive_get_pointer(ptr)));
}
/// @endcond
Modified: branches/release/boost/intrusive/circular_slist_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/circular_slist_algorithms.hpp (original)
+++ branches/release/boost/intrusive/circular_slist_algorithms.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -63,7 +63,7 @@
//! <b>Effects</b>: Constructs an non-used list element, putting the next
//! pointer to null:
- //! <tt>NodeTraits::get_next(this_node) == 0
+ //! <tt>NodeTraits::get_next(this_node) == 0</tt>
//!
//! <b>Complexity</b>: Constant
//!
Modified: branches/release/boost/intrusive/derivation_value_traits.hpp
==============================================================================
--- branches/release/boost/intrusive/derivation_value_traits.hpp (original)
+++ branches/release/boost/intrusive/derivation_value_traits.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -14,6 +14,7 @@
#define BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
#include <boost/intrusive/link_mode.hpp>
+#include <boost/pointer_cast.hpp>
#include <iterator>
namespace boost {
@@ -44,10 +45,20 @@
{ return node_ptr(&value); }
static pointer to_value_ptr(node_ptr n)
- { return pointer(static_cast<T*>(detail::get_pointer(n))); }
+ {
+// This still fails in gcc < 4.4 so forget about it
+// using ::boost::static_pointer_cast;
+// return static_pointer_cast<value_type>(n));
+ return pointer(&static_cast<value_type&>(*n));
+ }
static const_pointer to_value_ptr(const_node_ptr n)
- { return const_pointer(static_cast<const T*>(detail::get_pointer(n))); }
+ {
+// This still fails in gcc < 4.4 so forget about it
+// using ::boost::static_pointer_cast;
+// return static_pointer_cast<const value_type>(n));
+ return const_pointer(&static_cast<const value_type&>(*n));
+ }
};
} //namespace intrusive
Modified: branches/release/boost/intrusive/detail/any_node_and_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/any_node_and_algorithms.hpp (original)
+++ branches/release/boost/intrusive/detail/any_node_and_algorithms.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -19,6 +19,7 @@
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include <cstddef>
#include <boost/intrusive/detail/mpl.hpp>
+#include <boost/pointer_cast.hpp>
namespace boost {
namespace intrusive {
@@ -87,7 +88,10 @@
static const bool optimize_multikey = true;
static node_ptr get_next(const_node_ptr n)
- { return node_ptr(&static_cast<node &>(*n->node_ptr_1)); }
+ {
+ using ::boost::static_pointer_cast;
+ return static_pointer_cast<node>(n->node_ptr_1);
+ }
static void set_next(node_ptr n, node_ptr next)
{ n->node_ptr_1 = next; }
Modified: branches/release/boost/intrusive/detail/hashtable_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/hashtable_node.hpp (original)
+++ branches/release/boost/intrusive/detail/hashtable_node.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -22,7 +22,7 @@
#include <boost/intrusive/detail/utilities.hpp>
#include <boost/intrusive/detail/slist_node.hpp> //remove-me
#include <cstddef>
-
+#include <boost/pointer_cast.hpp>
namespace boost {
namespace intrusive {
namespace detail {
@@ -36,6 +36,7 @@
template<int Dummy>
const std::size_t prime_list_holder<Dummy>::prime_list[] = {
+ 3ul, 7ul, 11ul, 17ul, 29ul,
53ul, 97ul, 193ul, 389ul, 769ul,
1543ul, 3079ul, 6151ul, 12289ul, 24593ul,
49157ul, 98317ul, 196613ul, 393241ul, 786433ul,
@@ -117,7 +118,12 @@
typedef typename Container::size_type size_type;
static typename Container::node_ptr downcast_bucket(typename bucket_type::node_ptr p)
- { return typename Container::node_ptr(&static_cast<typename Container::node&>(*p)); }
+ {
+// This still fails in gcc < 4.4 so forget about it
+// using ::boost::static_pointer_cast;
+// return static_pointer_cast<typename Container::node>(p);
+ return typename Container::node_ptr(&static_cast<typename Container::node&>(*p));
+ }
public:
typedef typename Container::value_type value_type;
@@ -164,10 +170,10 @@
{ return *this->operator ->(); }
pointer operator->() const
- { return detail::get_pointer(this->get_real_value_traits()->to_value_ptr(downcast_bucket(slist_it_.pointed_node()))); }
+ { return detail::boost_intrusive_get_pointer(this->get_real_value_traits()->to_value_ptr(downcast_bucket(slist_it_.pointed_node()))); }
const Container *get_container() const
- { return detail::get_pointer(cont_); }
+ { return detail::boost_intrusive_get_pointer(cont_); }
const real_value_traits *get_real_value_traits() const
{ return &this->get_container()->get_real_value_traits(); }
@@ -175,8 +181,8 @@
private:
void increment()
{
- const Container *cont = detail::get_pointer(cont_);
- bucket_type* buckets = detail::get_pointer(cont->bucket_pointer());
+ const Container *cont = detail::boost_intrusive_get_pointer(cont_);
+ bucket_type* buckets = detail::boost_intrusive_get_pointer(cont->bucket_pointer());
size_type buckets_len = cont->bucket_count();
++slist_it_;
Modified: branches/release/boost/intrusive/detail/list_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/list_node.hpp (original)
+++ branches/release/boost/intrusive/detail/list_node.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -64,11 +64,9 @@
: public std::iterator
< std::bidirectional_iterator_tag
, typename Container::value_type
- , typename std::iterator_traits<typename Container::value_type*>::difference_type
- , typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type *
- , typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type &
+ , typename Container::difference_type
+ , typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type
+ , typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type
>
{
protected:
@@ -83,10 +81,8 @@
public:
typedef typename Container::value_type value_type;
- typedef typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type *pointer;
- typedef typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type &reference;
+ typedef typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type pointer;
+ typedef typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type reference;
list_iterator()
: members_ (node_ptr(0), 0)
@@ -133,17 +129,17 @@
return result;
}
- bool operator== (const list_iterator& i) const
- { return members_.nodeptr_ == i.pointed_node(); }
+ friend bool operator== (const list_iterator& l, const list_iterator& r)
+ { return l.pointed_node() == r.pointed_node(); }
- bool operator!= (const list_iterator& i) const
- { return !operator== (i); }
+ friend bool operator!= (const list_iterator& l, const list_iterator& r)
+ { return !(l == r); }
reference operator*() const
{ return *operator->(); }
pointer operator->() const
- { return detail::get_pointer(this->get_real_value_traits()->to_value_ptr(members_.nodeptr_)); }
+ { return detail::boost_intrusive_get_pointer(this->get_real_value_traits()->to_value_ptr(members_.nodeptr_)); }
const Container *get_container() const
{
Modified: branches/release/boost/intrusive/detail/parent_from_member.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/parent_from_member.hpp (original)
+++ branches/release/boost/intrusive/detail/parent_from_member.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -9,8 +9,8 @@
// See http://www.boost.org/libs/intrusive for documentation.
//
/////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP
-#define BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP
+#ifndef BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP
+#define BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP
#include <boost/intrusive/detail/config_begin.hpp>
#include <cstddef>
@@ -47,15 +47,13 @@
template<class Parent, class Member>
inline Parent *parent_from_member(Member *member, const Member Parent::* ptr_to_member)
{
- return (Parent*)((char*)member -
- offset_from_pointer_to_member(ptr_to_member));
+ return (Parent*)((char*)member - offset_from_pointer_to_member(ptr_to_member));
}
template<class Parent, class Member>
inline const Parent *parent_from_member(const Member *member, const Member Parent::* ptr_to_member)
{
- return (const Parent*)((const char*)member -
- offset_from_pointer_to_member(ptr_to_member));
+ return (const Parent*)((const char*)member - offset_from_pointer_to_member(ptr_to_member));
}
} //namespace detail {
@@ -68,4 +66,4 @@
#include <boost/intrusive/detail/config_end.hpp>
-#endif //#ifndef BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP
+#endif //#ifndef BOOST_INTRUSIVE_DETAIL_PARENT_FROM_MEMBER_HPP
Modified: branches/release/boost/intrusive/detail/slist_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/slist_node.hpp (original)
+++ branches/release/boost/intrusive/detail/slist_node.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -56,11 +56,9 @@
: public std::iterator
< std::forward_iterator_tag
, typename Container::value_type
- , typename std::iterator_traits<typename Container::value_type*>::difference_type
- , typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type *
- , typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type &
+ , typename Container::difference_type
+ , typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type
+ , typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type
>
{
protected:
@@ -75,10 +73,8 @@
public:
typedef typename Container::value_type value_type;
- typedef typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type *pointer;
- typedef typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type &reference;
+ typedef typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type pointer;
+ typedef typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type reference;
slist_iterator()
: members_ (node_ptr(0), 0)
@@ -112,17 +108,17 @@
return result;
}
- bool operator== (const slist_iterator& i) const
- { return members_.nodeptr_ == i.pointed_node(); }
+ friend bool operator== (const slist_iterator& l, const slist_iterator& r)
+ { return l.pointed_node() == r.pointed_node(); }
- bool operator!= (const slist_iterator& i) const
- { return !operator== (i); }
+ friend bool operator!= (const slist_iterator& l, const slist_iterator& r)
+ { return !(l == r); }
reference operator*() const
{ return *operator->(); }
pointer operator->() const
- { return detail::get_pointer(this->get_real_value_traits()->to_value_ptr(members_.nodeptr_)); }
+ { return detail::boost_intrusive_get_pointer(this->get_real_value_traits()->to_value_ptr(members_.nodeptr_)); }
const Container *get_container() const
{
Modified: branches/release/boost/intrusive/detail/tree_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/tree_algorithms.hpp (original)
+++ branches/release/boost/intrusive/detail/tree_algorithms.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -18,6 +18,7 @@
#include <boost/intrusive/intrusive_fwd.hpp>
#include <cstddef>
#include <boost/intrusive/detail/utilities.hpp>
+//iG pending #include <boost/pointer_cast.hpp>
namespace boost {
namespace intrusive {
@@ -140,7 +141,8 @@
static node_ptr uncast(const_node_ptr ptr)
{
- return node_ptr(const_cast<node*>(::boost::intrusive::detail::get_pointer(ptr)));
+ return node_ptr(const_cast<node*>(::boost::intrusive::detail::boost_intrusive_get_pointer(ptr)));
+ //iG pending return node_ptr(boost::const_pointer_cast<node>(ptr));
}
/// @endcond
@@ -1499,7 +1501,7 @@
static node_ptr vine_to_subtree(node_ptr old_root, std::size_t count)
{
- std::size_t leaf_nodes = count + 1 - ((size_t) 1 << floor_log2 (count + 1));
+ std::size_t leaf_nodes = count + 1 - ((std::size_t) 1 << floor_log2 (count + 1));
std::size_t vine_nodes = count - leaf_nodes;
node_ptr new_root = compress_subtree(old_root, leaf_nodes);
Modified: branches/release/boost/intrusive/detail/tree_node.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/tree_node.hpp (original)
+++ branches/release/boost/intrusive/detail/tree_node.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -73,11 +73,9 @@
: public std::iterator
< std::bidirectional_iterator_tag
, typename Container::value_type
- , typename std::iterator_traits<typename Container::value_type*>::difference_type
- , typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type *
- , typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type &
+ , typename Container::difference_type
+ , typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type
+ , typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type
>
{
protected:
@@ -93,10 +91,9 @@
public:
typedef typename Container::value_type value_type;
- typedef typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type *pointer;
- typedef typename detail::add_const_if_c
- <typename Container::value_type, IsConst>::type &reference;
+ typedef typename detail::if_c<IsConst,typename Container::const_pointer,typename Container::pointer>::type pointer;
+ typedef typename detail::if_c<IsConst,typename Container::const_reference,typename Container::reference>::type reference;
+
tree_iterator()
: members_ (0, 0)
@@ -143,17 +140,17 @@
return result;
}
- bool operator== (const tree_iterator& i) const
- { return members_.nodeptr_ == i.pointed_node(); }
+ friend bool operator== (const tree_iterator& l, const tree_iterator& r)
+ { return l.pointed_node() == r.pointed_node(); }
- bool operator!= (const tree_iterator& i) const
- { return !operator== (i); }
+ friend bool operator!= (const tree_iterator& l, const tree_iterator& r)
+ { return !(l == r); }
reference operator*() const
{ return *operator->(); }
pointer operator->() const
- { return detail::get_pointer(this->get_real_value_traits()->to_value_ptr(members_.nodeptr_)); }
+ { return detail::boost_intrusive_get_pointer(this->get_real_value_traits()->to_value_ptr(members_.nodeptr_)); }
const Container *get_container() const
{ return static_cast<const Container*>(members_.get_ptr()); }
Modified: branches/release/boost/intrusive/detail/utilities.hpp
==============================================================================
--- branches/release/boost/intrusive/detail/utilities.hpp (original)
+++ branches/release/boost/intrusive/detail/utilities.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -122,10 +122,10 @@
{ return ptr;}
};
-//!Overload for smart pointers to avoid ADL problems with get_pointer
+//!Overload for smart pointers to avoid ADL problems with boost_intrusive_get_pointer
template<class Ptr>
inline typename smart_ptr_type<Ptr>::pointer
-get_pointer(const Ptr &ptr)
+boost_intrusive_get_pointer(const Ptr &ptr)
{ return smart_ptr_type<Ptr>::get(ptr); }
//This functor compares a stored value
@@ -319,7 +319,7 @@
{}
const void *get_ptr() const
- { return detail::get_pointer(const_void_ptr_); }
+ { return detail::boost_intrusive_get_pointer(const_void_ptr_); }
ConstVoidPtr const_void_ptr_;
};
@@ -410,28 +410,63 @@
static const link_mode_type link_mode = Hook::boost_intrusive_tags::link_mode;
static node_ptr to_node_ptr(reference value)
- {
- return reinterpret_cast<node*>(&(value.*P));
- }
+ { return static_cast<node*>(&(value.*P)); }
static const_node_ptr to_node_ptr(const_reference value)
- {
- return static_cast<const node*>(&(value.*P));
- }
+ { return static_cast<const node*>(&(value.*P)); }
static pointer to_value_ptr(node_ptr n)
{
return detail::parent_from_member<T, Hook>
- (static_cast<Hook*>(detail::get_pointer(n)), P);
+ (static_cast<Hook*>(detail::boost_intrusive_get_pointer(n)), P);
}
static const_pointer to_value_ptr(const_node_ptr n)
{
return detail::parent_from_member<T, Hook>
- (static_cast<const Hook*>(detail::get_pointer(n)), P);
+ (static_cast<const Hook*>(detail::boost_intrusive_get_pointer(n)), P);
}
};
+template<class Functor>
+struct function_hook_traits
+{
+ public:
+ typedef typename Functor::hook_type hook_type;
+ typedef typename Functor::hook_ptr hook_ptr;
+ typedef typename Functor::const_hook_ptr const_hook_ptr;
+ typedef typename hook_type::boost_intrusive_tags::node_traits node_traits;
+ typedef typename node_traits::node node;
+ typedef typename Functor::value_type value_type;
+ typedef typename node_traits::node_ptr node_ptr;
+ typedef typename node_traits::const_node_ptr const_node_ptr;
+ typedef typename boost::pointer_to_other<node_ptr, value_type>::type pointer;
+ typedef typename boost::pointer_to_other<node_ptr, const value_type>::type const_pointer;
+ typedef typename std::iterator_traits<pointer>::reference reference;
+ typedef typename std::iterator_traits<const_pointer>::reference const_reference;
+ static const link_mode_type link_mode = hook_type::boost_intrusive_tags::link_mode;
+
+ static node_ptr to_node_ptr(reference value)
+ { return static_cast<node*>(&*Functor::to_hook_ptr(value)); }
+
+ static const_node_ptr to_node_ptr(const_reference value)
+ { return static_cast<const node*>(&*Functor::to_hook_ptr(value)); }
+
+ static pointer to_value_ptr(node_ptr n)
+ { return Functor::to_value_ptr(to_hook_ptr(n)); }
+
+ static const_pointer to_value_ptr(const_node_ptr n)
+ { return Functor::to_value_ptr(to_hook_ptr(n)); }
+
+ private:
+ static hook_ptr to_hook_ptr(node_ptr n)
+ { return hook_ptr(&*static_cast<hook_type*>(&*n)); }
+
+ static const_hook_ptr to_hook_ptr(const_node_ptr n)
+ { return const_hook_ptr(&*static_cast<const hook_type*>(&*n)); }
+};
+
+
//This function uses binary search to discover the
//highest set bit of the integer
inline std::size_t floor_log2 (std::size_t x)
@@ -454,14 +489,19 @@
inline float fast_log2 (float val)
{
- boost::uint32_t * exp_ptr =
- static_cast<boost::uint32_t *>(static_cast<void*>(&val));
- boost::uint32_t x = *exp_ptr;
+ union caster_t
+ {
+ boost::uint32_t x;
+ float val;
+ } caster;
+
+ caster.val = val;
+ boost::uint32_t x = caster.x;
const int log_2 = (int)(((x >> 23) & 255) - 128);
x &= ~(255 << 23);
x += 127 << 23;
- *exp_ptr = x;
-
+ caster.x = x;
+ val = caster.val;
val = ((-1.0f/3) * val + 2) * val - 2.0f/3;
return (val + log_2);
@@ -632,6 +672,64 @@
{ return *(this->get_real_value_traits()->to_value_ptr(npointer(&arg))); }
};
+//This is not standard, but should work with all compilers
+union max_align
+{
+ char char_;
+ short short_;
+ int int_;
+ long long_;
+ #ifdef BOOST_HAS_LONG_LONG
+ long long long_long_;
+ #endif
+ float float_;
+ double double_;
+ long double long_double_;
+ void * void_ptr_;
+};
+
+template<class T, std::size_t N>
+class array_initializer
+{
+ public:
+ template<class CommonInitializer>
+ array_initializer(const CommonInitializer &init)
+ {
+ char *init_buf = (char*)rawbuf;
+ std::size_t i = 0;
+ try{
+ for(; i != N; ++i){
+ new(init_buf)T(init);
+ init_buf += sizeof(T);
+ }
+ }
+ catch(...){
+ while(i--){
+ init_buf -= sizeof(T);
+ ((T*)init_buf)->~T();
+ }
+ throw;
+ }
+ }
+
+ operator T* ()
+ { return (T*)(rawbuf); }
+
+ operator const T*() const
+ { return (const T*)(rawbuf); }
+
+ ~array_initializer()
+ {
+ char *init_buf = (char*)rawbuf + N*sizeof(T);
+ for(std::size_t i = 0; i != N; ++i){
+ init_buf -= sizeof(T);
+ ((T*)init_buf)->~T();
+ }
+ }
+
+ private:
+ detail::max_align rawbuf[(N*sizeof(T)-1)/sizeof(detail::max_align)+1];
+};
} //namespace detail
} //namespace intrusive
Modified: branches/release/boost/intrusive/hashtable.hpp
==============================================================================
--- branches/release/boost/intrusive/hashtable.hpp (original)
+++ branches/release/boost/intrusive/hashtable.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -23,6 +23,7 @@
#include <boost/intrusive/detail/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/functional/hash.hpp>
+#include <boost/pointer_cast.hpp>
//General intrusive utilities
#include <boost/intrusive/intrusive_fwd.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
@@ -157,26 +158,22 @@
template<class SupposedValueTraits>
struct unordered_bucket_impl
{
- /// @cond
typedef typename
get_slist_impl_from_supposed_value_traits
<SupposedValueTraits>::type slist_impl;
typedef detail::bucket_impl<slist_impl> implementation_defined;
- /// @endcond
typedef implementation_defined type;
};
template<class SupposedValueTraits>
struct unordered_bucket_ptr_impl
{
- /// @cond
typedef typename detail::get_node_traits
<SupposedValueTraits>::type::node_ptr node_ptr;
typedef typename unordered_bucket_impl
<SupposedValueTraits>::type bucket_type;
typedef typename boost::pointer_to_other
<node_ptr, bucket_type>::type implementation_defined;
- /// @endcond
typedef implementation_defined type;
};
@@ -329,7 +326,12 @@
typedef circular_slist_algorithms<group_traits> group_algorithms;
static node_ptr dcast_bucket_ptr(slist_node_ptr p)
- { return node_ptr(&static_cast<node&>(*p)); }
+ {
+// This still fails in gcc < 4.4 so forget about it
+// using ::boost::static_pointer_cast;
+// return static_pointer_cast<node>(p);
+ return node_ptr(&static_cast<node&>(*p));
+ }
static slist_node_ptr priv_get_bucket_before_begin
(slist_node_ptr bucket_beg, slist_node_ptr bucket_end, node_ptr p)
@@ -496,7 +498,6 @@
template<class ValueTraitsOrHookOption>
struct unordered_default_bucket_traits
{
- /// @cond
typedef typename ValueTraitsOrHookOption::
template pack<none>::value_traits supposed_value_traits;
typedef typename detail::
@@ -504,7 +505,6 @@
<supposed_value_traits>::type slist_impl;
typedef detail::bucket_traits_impl
<slist_impl> implementation_defined;
- /// @endcond
typedef implementation_defined type;
};
@@ -886,7 +886,7 @@
}
else{
size_type buckets_len = this->priv_buckets_len();
- const bucket_type *b = detail::get_pointer(this->priv_buckets());
+ const bucket_type *b = detail::boost_intrusive_get_pointer(this->priv_buckets());
for (size_type n = 0; n < buckets_len; ++n, ++b){
if(!b->empty()){
return false;
@@ -909,7 +909,7 @@
else{
size_type len = 0;
size_type buckets_len = this->priv_buckets_len();
- const bucket_type *b = detail::get_pointer(this->priv_buckets());
+ const bucket_type *b = detail::boost_intrusive_get_pointer(this->priv_buckets());
for (size_type n = 0; n < buckets_len; ++n, ++b){
len += b->size();
}
@@ -1229,8 +1229,8 @@
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased element. No destructors are called.
- iterator erase(const_iterator i)
- { return this->erase_and_dispose(i, detail::null_disposer()); }
+ void erase(const_iterator i)
+ { this->erase_and_dispose(i, detail::null_disposer()); }
//! <b>Effects</b>: Erases the range pointed to by b end e.
//!
@@ -1241,8 +1241,8 @@
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased elements. No destructors are called.
- iterator erase(const_iterator b, const_iterator e)
- { return this->erase_and_dispose(b, e, detail::null_disposer()); }
+ void erase(const_iterator b, const_iterator e)
+ { this->erase_and_dispose(b, e, detail::null_disposer()); }
//! <b>Effects</b>: Erases all the elements with the given value.
//!
@@ -1295,18 +1295,15 @@
//! <b>Note</b>: Invalidates the iterators
//! to the erased elements.
template<class Disposer>
- iterator erase_and_dispose(const_iterator i, Disposer disposer
+ void erase_and_dispose(const_iterator i, Disposer disposer
/// @cond
, typename detail::enable_if_c<!detail::is_convertible<Disposer, const_iterator>::value >::type * = 0
/// @endcond
)
{
- iterator ret(i.unconst());
- ++ret;
priv_erase(i, disposer, optimize_multikey_t());
this->priv_size_traits().decrement();
priv_erasure_update_cache();
- return ret;
}
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
@@ -1322,7 +1319,7 @@
//! <b>Note</b>: Invalidates the iterators
//! to the erased elements.
template<class Disposer>
- iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
+ void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
{
if(b != e){
//Get the bucket number and local iterator for both iterators
@@ -1347,7 +1344,6 @@
priv_erase_range(before_first_local_it, first_bucket_num, last_local_it, last_bucket_num, disposer);
priv_erasure_update_cache(first_bucket_num, last_bucket_num);
}
- return e.unconst();
}
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
@@ -2139,8 +2135,8 @@
}
//! <b>Effects</b>: Returns the nearest new bucket count optimized for
- //! the container that is bigger than n. This suggestion can be used
- //! to create bucket arrays with a size that will usually improve
+ //! the container that is bigger or equal than n. This suggestion can be
+ //! used to create bucket arrays with a size that will usually improve
//! container's performance. If such value does not exist, the
//! higher possible value is returned.
//!
@@ -2153,15 +2149,15 @@
const std::size_t *primes_end = primes + detail::prime_list_holder<0>::prime_list_size;
size_type const* bound = std::lower_bound(primes, primes_end, n);
if(bound == primes_end)
- bound--;
+ --bound;
return size_type(*bound);
}
//! <b>Effects</b>: Returns the nearest new bucket count optimized for
- //! the container that is smaller than n. This suggestion can be used
- //! to create bucket arrays with a size that will usually improve
+ //! the container that is smaller or equal than n. This suggestion can be
+ //! used to create bucket arrays with a size that will usually improve
//! container's performance. If such value does not exist, the
- //! lower possible value is returned.
+ //! lowest possible value is returned.
//!
//! <b>Complexity</b>: Amortized constant time.
//!
@@ -2171,8 +2167,8 @@
const std::size_t *primes = &detail::prime_list_holder<0>::prime_list[0];
const std::size_t *primes_end = primes + detail::prime_list_holder<0>::prime_list_size;
size_type const* bound = std::upper_bound(primes, primes_end, n);
- if(bound != primes_end)
- bound--;
+ if(bound != primes)
+ --bound;
return size_type(*bound);
}
@@ -2240,7 +2236,7 @@
{ return this->priv_real_bucket_traits().bucket_count(); }
static node_ptr uncast(const_node_ptr ptr)
- { return node_ptr(const_cast<node*>(detail::get_pointer(ptr))); }
+ { return node_ptr(const_cast<node*>(detail::boost_intrusive_get_pointer(ptr))); }
node &priv_value_to_node(value_type &v)
{ return *this->get_real_value_traits().to_node_ptr(v); }
@@ -2326,7 +2322,12 @@
}
static node_ptr dcast_bucket_ptr(typename slist_impl::node_ptr p)
- { return node_ptr(&static_cast<node&>(*p)); }
+ {
+// This still fails in gcc < 4.4 so forget about it
+// using ::boost::static_pointer_cast;
+// return static_pointer_cast<node>(p);
+ return node_ptr(&static_cast<node&>(*p));
+ }
std::size_t priv_stored_or_compute_hash(const value_type &v, detail::true_) const
{ return node_traits::get_hash(this->get_real_value_traits().to_node_ptr(v)); }
@@ -2893,7 +2894,6 @@
//Real value traits must be calculated from options
typedef typename detail::get_value_traits
<T, typename packed_options::value_traits>::type value_traits;
- /// @cond
static const bool external_value_traits =
detail::external_value_traits_is_true<value_traits>::value;
typedef typename detail::eval_if_c
@@ -2902,7 +2902,6 @@
, detail::identity<value_traits>
>::type real_value_traits;
typedef typename packed_options::bucket_traits specified_bucket_traits;
- /// @endcond
//Real bucket traits must be calculated from options and calculated value_traits
typedef typename detail::get_slist_impl
Modified: branches/release/boost/intrusive/intrusive_fwd.hpp
==============================================================================
--- branches/release/boost/intrusive/intrusive_fwd.hpp (original)
+++ branches/release/boost/intrusive/intrusive_fwd.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -50,7 +50,7 @@
////////////////////////////
//slist
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -64,7 +64,7 @@
#endif
class slist;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -75,7 +75,7 @@
#endif
class slist_base_hook;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -87,7 +87,7 @@
class slist_member_hook;
//list
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -99,7 +99,7 @@
#endif
class list;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -110,7 +110,7 @@
#endif
class list_base_hook;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -121,8 +121,19 @@
#endif
class list_member_hook;
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
+template
+ < class O1 = none
+ , class O2 = none
+ , class O3 = none
+ >
+#else
+template<class ...Options>
+#endif
+class list_hook;
+
//rbtree/set/multiset
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -135,7 +146,7 @@
#endif
class rbtree;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -148,7 +159,7 @@
#endif
class set;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -161,7 +172,7 @@
#endif
class multiset;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -173,7 +184,7 @@
#endif
class set_base_hook;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -186,7 +197,7 @@
class set_member_hook;
//splaytree/splay_set/splay_multiset
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -199,7 +210,7 @@
#endif
class splaytree;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -212,7 +223,7 @@
#endif
class splay_set;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -225,7 +236,7 @@
#endif
class splay_multiset;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -236,7 +247,7 @@
#endif
class splay_set_base_hook;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -248,7 +259,7 @@
class splay_set_member_hook;
//avltree/avl_set/avl_multiset
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -261,7 +272,7 @@
#endif
class avltree;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -274,7 +285,7 @@
#endif
class avl_set;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -287,7 +298,7 @@
#endif
class avl_multiset;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -299,7 +310,7 @@
#endif
class avl_set_base_hook;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -313,7 +324,7 @@
//treap/treap_set/treap_multiset
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -326,7 +337,7 @@
#endif
class treap;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -339,7 +350,7 @@
#endif
class treap_set;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -357,7 +368,7 @@
struct priority_compare;
//sgtree/sg_set/sg_multiset
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -370,7 +381,7 @@
#endif
class sgtree;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -383,7 +394,7 @@
#endif
class sg_set;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -396,7 +407,7 @@
#endif
class sg_multiset;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -407,7 +418,7 @@
#endif
class bs_set_base_hook;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -420,7 +431,7 @@
//hashtable/unordered_set/unordered_multiset
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -439,7 +450,7 @@
#endif
class hashtable;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -458,7 +469,7 @@
#endif
class unordered_set;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class T
, class O1 = none
@@ -477,7 +488,7 @@
#endif
class unordered_multiset;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -489,7 +500,7 @@
#endif
class unordered_set_base_hook;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -501,7 +512,7 @@
#endif
class unordered_set_member_hook;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
@@ -512,7 +523,7 @@
#endif
class any_base_hook;
-#ifndef BOOST_INTRUSIVE_VARIADIC_TEMPLATES
+#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) && !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
template
< class O1 = none
, class O2 = none
Modified: branches/release/boost/intrusive/list.hpp
==============================================================================
--- branches/release/boost/intrusive/list.hpp (original)
+++ branches/release/boost/intrusive/list.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -30,6 +30,7 @@
#include <algorithm>
#include <functional>
#include <cstddef>
+//iG pending #include <boost/pointer_cast.hpp>
namespace boost {
namespace intrusive {
@@ -129,8 +130,8 @@
//Const cast emulation for smart pointers
static node_ptr uncast(const_node_ptr ptr)
{
- //return node_ptr(detail::get_pointer(ptr)));
- return const_cast<node*>(detail::get_pointer(ptr));
+ return const_cast<node*>(detail::boost_intrusive_get_pointer(ptr));
+ //iG pending return node_ptr(boost::const_pointer_cast<node>(ptr));
}
node_ptr get_root_node()
@@ -172,6 +173,22 @@
real_value_traits &get_real_value_traits(detail::bool_<true>)
{ return data_.get_value_traits(*this); }
+ const value_traits &get_value_traits() const
+ { return data_; }
+
+ value_traits &get_value_traits()
+ { return data_; }
+
+ protected:
+ node &prot_root_node()
+ { return data_.root_plus_size_.root_; }
+
+ node const &prot_root_node() const
+ { return data_.root_plus_size_.root_; }
+
+ void prot_set_size(size_type s)
+ { data_.root_plus_size_.set_size(s); }
+
/// @endcond
public:
@@ -971,8 +988,8 @@
{
if(node_traits::get_next(this->get_root_node())
!= node_traits::get_previous(this->get_root_node())){
- list_impl carry;
- list_impl counter[64];
+ list_impl carry(this->get_value_traits());
+ detail::array_initializer<list_impl, 64> counter(this->get_value_traits());
int fill = 0;
while(!this->empty()){
carry.splice(carry.cbegin(), *this, this->cbegin());
@@ -1268,7 +1285,7 @@
static list_impl &priv_container_from_end_iterator(const const_iterator &end_iterator)
{
root_plus_size *r = detail::parent_from_member<root_plus_size, node>
- ( detail::get_pointer(end_iterator.pointed_node()), &root_plus_size::root_);
+ ( detail::boost_intrusive_get_pointer(end_iterator.pointed_node()), &root_plus_size::root_);
data_t *d = detail::parent_from_member<data_t, root_plus_size>
( r, &data_t::root_plus_size_);
list_impl *s = detail::parent_from_member<list_impl, data_t>(d, &list_impl::data_);
Modified: branches/release/boost/intrusive/options.hpp
==============================================================================
--- branches/release/boost/intrusive/options.hpp (original)
+++ branches/release/boost/intrusive/options.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -343,6 +343,24 @@
};
+//!This option setter specifies the function object that will
+//!be used to convert between values to be inserted in a container
+//!and the hook to be used for that purpose.
+template< typename Functor>
+struct function_hook
+{
+/// @cond
+ typedef detail::function_hook_traits
+ <Functor> function_value_traits;
+ template<class Base>
+ struct pack : Base
+ {
+ typedef function_value_traits value_traits;
+ };
+/// @endcond
+};
+
+
//!This option setter specifies that the container
//!must use the specified base hook
template<typename BaseHook>
Added: branches/release/boost/intrusive/parent_from_member.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/intrusive/parent_from_member.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -0,0 +1,42 @@
+/////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2010-2010
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/intrusive for documentation.
+//
+/////////////////////////////////////////////////////////////////////////////
+#ifndef BOOST_INTRUSIVE_GET_PARENT_FROM_MEMBER_HPP
+#define BOOST_INTRUSIVE_GET_PARENT_FROM_MEMBER_HPP
+
+#include <boost/intrusive/detail/config_begin.hpp>
+#include <boost/intrusive/detail/parent_from_member.hpp>
+
+namespace boost {
+namespace intrusive {
+
+//! Given a pointer to a member and its corresponding pointer to data member,
+//! this function returns the pointer of the parent containing that member.
+//! Note: this function does not work with pointer to members that rely on
+//! virtual inheritance.
+template<class Parent, class Member>
+inline Parent *get_parent_from_member(Member *member, const Member Parent::* ptr_to_member)
+{ return ::boost::intrusive::detail::parent_from_member(member, ptr_to_member); }
+
+//! Given a const pointer to a member and its corresponding const pointer to data member,
+//! this function returns the const pointer of the parent containing that member.
+//! Note: this function does not work with pointer to members that rely on
+//! virtual inheritance.
+template<class Parent, class Member>
+inline const Parent *get_parent_from_member(const Member *member, const Member Parent::* ptr_to_member)
+{ return ::boost::intrusive::detail::parent_from_member(member, ptr_to_member); }
+
+} //namespace intrusive {
+} //namespace boost {
+
+#include <boost/intrusive/detail/config_end.hpp>
+
+#endif //#ifndef BOOST_INTRUSIVE_GET_PARENT_FROM_MEMBER_HPP
Modified: branches/release/boost/intrusive/rbtree.hpp
==============================================================================
--- branches/release/boost/intrusive/rbtree.hpp (original)
+++ branches/release/boost/intrusive/rbtree.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -33,6 +33,7 @@
#include <boost/intrusive/options.hpp>
#include <boost/intrusive/rbtree_algorithms.hpp>
#include <boost/intrusive/link_mode.hpp>
+//iG pending #include <boost/pointer_cast.hpp>
namespace boost {
namespace intrusive {
@@ -110,10 +111,8 @@
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef typename real_value_traits::node_traits node_traits;
typedef typename node_traits::node node;
- typedef typename boost::pointer_to_other
- <pointer, node>::type node_ptr;
- typedef typename boost::pointer_to_other
- <node_ptr, const node>::type const_node_ptr;
+ typedef typename node_traits::node_ptr node_ptr;
+ typedef typename node_traits::const_node_ptr const_node_ptr;
typedef rbtree_algorithms<node_traits> node_algorithms;
static const bool constant_time_size = Config::constant_time_size;
@@ -152,7 +151,7 @@
{}
node_plus_pred_t node_plus_pred_;
} data_;
-
+
const value_compare &priv_comp() const
{ return data_.node_plus_pred_.get(); }
@@ -167,7 +166,8 @@
static node_ptr uncast(const_node_ptr ptr)
{
- return node_ptr(const_cast<node*>(detail::get_pointer(ptr)));
+ return node_ptr(const_cast<node*>(detail::boost_intrusive_get_pointer(ptr)));
+//iG pending return node_ptr(boost::const_pointer_cast<node>(ptr));
}
size_traits &priv_size_traits()
@@ -188,6 +188,19 @@
real_value_traits &get_real_value_traits(detail::bool_<true>)
{ return data_.get_value_traits(*this); }
+ protected:
+ value_compare &prot_comp()
+ { return priv_comp(); }
+
+ const node &prot_header_node() const
+ { return priv_header(); }
+
+ node &prot_header_node()
+ { return priv_header(); }
+
+ void prot_set_size(size_type s)
+ { this->priv_size_traits().set_size(s); }
+
/// @endcond
public:
@@ -1390,7 +1403,7 @@
static rbtree_impl &priv_container_from_end_iterator(const const_iterator &end_iterator)
{
header_plus_size *r = detail::parent_from_member<header_plus_size, node>
- ( detail::get_pointer(end_iterator.pointed_node()), &header_plus_size::header_);
+ ( detail::boost_intrusive_get_pointer(end_iterator.pointed_node()), &header_plus_size::header_);
node_plus_pred_t *n = detail::parent_from_member
<node_plus_pred_t, header_plus_size>(r, &node_plus_pred_t::header_plus_size_);
data_t *d = detail::parent_from_member<data_t, node_plus_pred_t>(n, &data_t::node_plus_pred_);
Modified: branches/release/boost/intrusive/rbtree_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/rbtree_algorithms.hpp (original)
+++ branches/release/boost/intrusive/rbtree_algorithms.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -57,7 +57,6 @@
#include <boost/intrusive/detail/utilities.hpp>
#include <boost/intrusive/detail/tree_algorithms.hpp>
-
namespace boost {
namespace intrusive {
@@ -157,7 +156,7 @@
static node_ptr uncast(const_node_ptr ptr)
{
- return node_ptr(const_cast<node*>(::boost::intrusive::detail::get_pointer(ptr)));
+ return node_ptr(const_cast<node*>(::boost::intrusive::detail::boost_intrusive_get_pointer(ptr)));
}
/// @endcond
Modified: branches/release/boost/intrusive/set.hpp
==============================================================================
--- branches/release/boost/intrusive/set.hpp (original)
+++ branches/release/boost/intrusive/set.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -75,9 +75,19 @@
typedef typename implementation_defined::const_node_ptr const_node_ptr;
typedef typename implementation_defined::node_algorithms node_algorithms;
+ static const bool constant_time_size = Config::constant_time_size;
+ //static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value;
+
/// @cond
private:
tree_type tree_;
+
+ protected:
+ node &prot_header_node(){ return tree_.prot_header_node(); }
+ node const &prot_header_node() const{ return tree_.prot_header_node(); }
+ void prot_set_size(size_type s){ tree_.prot_set_size(s); }
+ value_compare &prot_comp(){ return tree_.prot_comp(); }
+
/// @endcond
public:
@@ -1265,9 +1275,18 @@
typedef typename implementation_defined::const_node_ptr const_node_ptr;
typedef typename implementation_defined::node_algorithms node_algorithms;
+ static const bool constant_time_size = Config::constant_time_size;
+ //static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value;
+
/// @cond
private:
tree_type tree_;
+
+ protected:
+ node &prot_header_node(){ return tree_.prot_header_node(); }
+ node const &prot_header_node() const{ return tree_.prot_header_node(); }
+ void prot_set_size(size_type s){ tree_.prot_set_size(s); }
+ value_compare &prot_comp(){ return tree_.prot_comp(); }
/// @endcond
public:
@@ -1450,7 +1469,7 @@
//!
//! <b>Throws</b>: Nothing.
//!
- //! <b>Complexity</b>: Constant.
+ //! <b>Complexity</b>: Logarithmic.
static multiset_impl &container_from_iterator(iterator it)
{
return *detail::parent_from_member<multiset_impl, tree_type>
@@ -1464,7 +1483,7 @@
//!
//! <b>Throws</b>: Nothing.
//!
- //! <b>Complexity</b>: Constant.
+ //! <b>Complexity</b>: Logarithmic.
static const multiset_impl &container_from_iterator(const_iterator it)
{
return *detail::parent_from_member<multiset_impl, tree_type>
Modified: branches/release/boost/intrusive/sgtree_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/sgtree_algorithms.hpp (original)
+++ branches/release/boost/intrusive/sgtree_algorithms.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -70,7 +70,7 @@
static node_ptr uncast(const_node_ptr ptr)
{
- return node_ptr(const_cast<node*>(::boost::intrusive::detail::get_pointer(ptr)));
+ return node_ptr(const_cast<node*>(::boost::intrusive::detail::boost_intrusive_get_pointer(ptr)));
}
/// @endcond
Modified: branches/release/boost/intrusive/splay_set.hpp
==============================================================================
--- branches/release/boost/intrusive/splay_set.hpp (original)
+++ branches/release/boost/intrusive/splay_set.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -74,6 +74,8 @@
typedef typename implementation_defined::const_node_ptr const_node_ptr;
typedef typename implementation_defined::node_algorithms node_algorithms;
+ static const bool constant_time_size = Config::constant_time_size;
+
/// @cond
private:
tree_type tree_;
@@ -1286,6 +1288,8 @@
typedef typename implementation_defined::const_node_ptr const_node_ptr;
typedef typename implementation_defined::node_algorithms node_algorithms;
+ static const bool constant_time_size = Config::constant_time_size;
+
/// @cond
private:
tree_type tree_;
Modified: branches/release/boost/intrusive/splaytree.hpp
==============================================================================
--- branches/release/boost/intrusive/splaytree.hpp (original)
+++ branches/release/boost/intrusive/splaytree.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -166,7 +166,7 @@
static node_ptr uncast(const_node_ptr ptr)
{
- return node_ptr(const_cast<node*>(detail::get_pointer(ptr)));
+ return node_ptr(const_cast<node*>(detail::boost_intrusive_get_pointer(ptr)));
}
size_traits &priv_size_traits()
@@ -1405,7 +1405,7 @@
static splaytree_impl &priv_container_from_end_iterator(const const_iterator &end_iterator)
{
header_plus_size *r = detail::parent_from_member<header_plus_size, node>
- ( detail::get_pointer(end_iterator.pointed_node()), &header_plus_size::header_);
+ ( detail::boost_intrusive_get_pointer(end_iterator.pointed_node()), &header_plus_size::header_);
node_plus_pred_t *n = detail::parent_from_member
<node_plus_pred_t, header_plus_size>(r, &node_plus_pred_t::header_plus_size_);
data_t *d = detail::parent_from_member<data_t, node_plus_pred_t>(n, &data_t::node_plus_pred_);
Modified: branches/release/boost/intrusive/splaytree_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/splaytree_algorithms.hpp (original)
+++ branches/release/boost/intrusive/splaytree_algorithms.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -147,7 +147,7 @@
private:
static node_ptr uncast(const_node_ptr ptr)
{
- return node_ptr(const_cast<node*>(::boost::intrusive::detail::get_pointer(ptr)));
+ return node_ptr(const_cast<node*>(::boost::intrusive::detail::boost_intrusive_get_pointer(ptr)));
}
/// @endcond
Modified: branches/release/boost/intrusive/treap.hpp
==============================================================================
--- branches/release/boost/intrusive/treap.hpp (original)
+++ branches/release/boost/intrusive/treap.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -116,7 +116,7 @@
<pointer, node>::type node_ptr;
typedef typename boost::pointer_to_other
<node_ptr, const node>::type const_node_ptr;
- typedef treap_algorithms<node_traits> node_algorithms;
+ typedef treap_algorithms<node_traits> node_algorithms;
static const bool constant_time_size = Config::constant_time_size;
static const bool stateful_value_traits = detail::is_stateful_value_traits<real_value_traits>::value;
@@ -184,7 +184,7 @@
static node_ptr uncast(const_node_ptr ptr)
{
- return node_ptr(const_cast<node*>(detail::get_pointer(ptr)));
+ return node_ptr(const_cast<node*>(detail::boost_intrusive_get_pointer(ptr)));
}
size_traits &priv_size_traits()
@@ -1482,7 +1482,7 @@
static treap_impl &priv_container_from_end_iterator(const const_iterator &end_iterator)
{
header_plus_size *r = detail::parent_from_member<header_plus_size, node>
- ( detail::get_pointer(end_iterator.pointed_node()), &header_plus_size::header_);
+ ( detail::boost_intrusive_get_pointer(end_iterator.pointed_node()), &header_plus_size::header_);
typename node_plus_pred_t::header_plus_priority_size *n =
detail::parent_from_member
< typename node_plus_pred_t::header_plus_priority_size
Modified: branches/release/boost/intrusive/treap_algorithms.hpp
==============================================================================
--- branches/release/boost/intrusive/treap_algorithms.hpp (original)
+++ branches/release/boost/intrusive/treap_algorithms.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -145,7 +145,7 @@
static node_ptr uncast(const_node_ptr ptr)
{
- return node_ptr(const_cast<node*>(::boost::intrusive::detail::get_pointer(ptr)));
+ return node_ptr(const_cast<node*>(::boost::intrusive::detail::boost_intrusive_get_pointer(ptr)));
}
/// @endcond
Modified: branches/release/boost/intrusive/treap_set.hpp
==============================================================================
--- branches/release/boost/intrusive/treap_set.hpp (original)
+++ branches/release/boost/intrusive/treap_set.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -75,6 +75,8 @@
typedef typename implementation_defined::const_node_ptr const_node_ptr;
typedef typename implementation_defined::node_algorithms node_algorithms;
+ static const bool constant_time_size = Config::constant_time_size;
+
/// @cond
private:
tree_type tree_;
@@ -1382,6 +1384,8 @@
typedef typename implementation_defined::const_node_ptr const_node_ptr;
typedef typename implementation_defined::node_algorithms node_algorithms;
+ static const bool constant_time_size = Config::constant_time_size;
+
/// @cond
private:
tree_type tree_;
Modified: branches/release/boost/intrusive/unordered_set.hpp
==============================================================================
--- branches/release/boost/intrusive/unordered_set.hpp (original)
+++ branches/release/boost/intrusive/unordered_set.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -248,7 +248,7 @@
//! <b>Effects</b>: Returns the number of elements stored in the unordered_set.
//!
//! <b>Complexity</b>: Linear to elements contained in *this if
- //! constant-time size option is enabled. Constant-time otherwise.
+ //! constant-time size option is disabled. Constant-time otherwise.
//!
//! <b>Throws</b>: Nothing.
size_type size() const
@@ -395,8 +395,8 @@
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased element. No destructors are called.
- iterator erase(const_iterator i)
- { return table_.erase(i); }
+ void erase(const_iterator i)
+ { table_.erase(i); }
//! <b>Effects</b>: Erases the range pointed to by b end e.
//!
@@ -407,8 +407,8 @@
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased elements. No destructors are called.
- iterator erase(const_iterator b, const_iterator e)
- { return table_.erase(b, e); }
+ void erase(const_iterator b, const_iterator e)
+ { table_.erase(b, e); }
//! <b>Effects</b>: Erases all the elements with the given value.
//!
@@ -460,12 +460,12 @@
//! <b>Note</b>: Invalidates the iterators
//! to the erased elements.
template<class Disposer>
- iterator erase_and_dispose(const_iterator i, Disposer disposer
+ void erase_and_dispose(const_iterator i, Disposer disposer
/// @cond
, typename detail::enable_if_c<!detail::is_convertible<Disposer, const_iterator>::value >::type * = 0
/// @endcond
)
- { return table_.erase_and_dispose(i, disposer); }
+ { table_.erase_and_dispose(i, disposer); }
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
//!
@@ -480,8 +480,8 @@
//! <b>Note</b>: Invalidates the iterators
//! to the erased elements.
template<class Disposer>
- iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
- { return table_.erase_and_dispose(b, e, disposer); }
+ void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
+ { table_.erase_and_dispose(b, e, disposer); }
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
//!
@@ -1305,7 +1305,7 @@
//! <b>Effects</b>: Returns the number of elements stored in the unordered_multiset.
//!
//! <b>Complexity</b>: Linear to elements contained in *this if
- //! constant-time size option is enabled. Constant-time otherwise.
+ //! constant-time size option is disabled. Constant-time otherwise.
//!
//! <b>Throws</b>: Nothing.
size_type size() const
@@ -1387,8 +1387,8 @@
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased element. No destructors are called.
- iterator erase(const_iterator i)
- { return table_.erase(i); }
+ void erase(const_iterator i)
+ { table_.erase(i); }
//! <b>Effects</b>: Erases the range pointed to by b end e.
//!
@@ -1399,8 +1399,8 @@
//!
//! <b>Note</b>: Invalidates the iterators (but not the references)
//! to the erased elements. No destructors are called.
- iterator erase(const_iterator b, const_iterator e)
- { return table_.erase(b, e); }
+ void erase(const_iterator b, const_iterator e)
+ { table_.erase(b, e); }
//! <b>Effects</b>: Erases all the elements with the given value.
//!
@@ -1453,17 +1453,17 @@
//! <b>Note</b>: Invalidates the iterators
//! to the erased elements.
template<class Disposer>
- iterator erase_and_dispose(const_iterator i, Disposer disposer
+ void erase_and_dispose(const_iterator i, Disposer disposer
/// @cond
, typename detail::enable_if_c<!detail::is_convertible<Disposer, const_iterator>::value >::type * = 0
/// @endcond
)
- { return table_.erase_and_dispose(i, disposer); }
+ { table_.erase_and_dispose(i, disposer); }
#if !defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
template<class Disposer>
- iterator erase_and_dispose(const_iterator i, Disposer disposer)
- { return this->erase_and_dispose(const_iterator(i), disposer); }
+ void erase_and_dispose(const_iterator i, Disposer disposer)
+ { this->erase_and_dispose(const_iterator(i), disposer); }
#endif
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
@@ -1479,8 +1479,8 @@
//! <b>Note</b>: Invalidates the iterators
//! to the erased elements.
template<class Disposer>
- iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
- { return table_.erase_and_dispose(b, e, disposer); }
+ void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer)
+ { table_.erase_and_dispose(b, e, disposer); }
//! <b>Requires</b>: Disposer::operator()(pointer) shouldn't throw.
//!
Modified: branches/release/boost/intrusive/unordered_set_hook.hpp
==============================================================================
--- branches/release/boost/intrusive/unordered_set_hook.hpp (original)
+++ branches/release/boost/intrusive/unordered_set_hook.hpp 2010-08-26 17:51:03 EDT (Thu, 26 Aug 2010)
@@ -16,6 +16,7 @@
#include <boost/intrusive/detail/config_begin.hpp>
#include <boost/intrusive/intrusive_fwd.hpp>
+#include <boost/pointer_cast.hpp>
#include <boost/intrusive/detail/utilities.hpp>
#include <boost/intrusive/detail/pointer_to_other.hpp>
#include <boost/intrusive/slist_hook.hpp>
@@ -76,7 +77,12 @@
static const bool optimize_multikey = OptimizeMultiKey;
static node_ptr get_next(const_node_ptr n)
- { return node_ptr(&static_cast<node &>(*n->next_)); }
+ {
+// This still fails in gcc < 4.4 so forget about it
+// using ::boost::static_pointer_cast;
+// return static_pointer_cast<node>(n->next_);
+ return node_ptr(&static_cast<node&>(*n->next_));
+ }
static void set_next(node_ptr n, node_ptr next)
{ n->next_ = next; }
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk