diff --git a/include/boost/intrusive/detail/assert.hpp b/include/boost/intrusive/detail/assert.hpp new file mode 100644 index 0000000..f44a971 --- /dev/null +++ b/include/boost/intrusive/detail/assert.hpp @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-2007 +// +// 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_DETAIL_ASSERT_HPP +#define BOOST_INTRUSIVE_DETAIL_ASSERT_HPP + +#if defined(_MSC_VER)&&(_MSC_VER>=1200) +#pragma once +#endif + +#if !defined(BOOST_INTRUSIVE_INVARIANT_ASSERT) +#include +#define BOOST_INTRUSIVE_INVARIANT_ASSERT BOOST_ASSERT +#endif + +#if !defined(BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT) +#include +#define BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT BOOST_ASSERT +#endif + +#if !defined(BOOST_INTRUSIVE_SAFE_MODE_HOOK_DESTRUCTOR_ASSERT) +#include +#define BOOST_INTRUSIVE_SAFE_MODE_HOOK_DESTRUCTOR_ASSERT BOOST_ASSERT +#endif + +#endif //BOOST_INTRUSIVE_DETAIL_ASSERT_HPP diff --git a/include/boost/intrusive/detail/config_begin.hpp b/include/boost/intrusive/detail/config_begin.hpp index 1f87d65..06a0b85 100644 --- a/include/boost/intrusive/detail/config_begin.hpp +++ b/include/boost/intrusive/detail/config_begin.hpp @@ -9,9 +9,18 @@ // See http://www.boost.org/libs/intrusive for documentation. // ///////////////////////////////////////////////////////////////////////////// + +#ifndef BOOST_INTRUSIVE_SELECT_COMPILER_INCLUDED +#ifndef BOOST_COMPILER_CONFIG +//#include +//#include BOOST_COMPILER_CONFIG #include +#endif +#define BOOST_INTRUSIVE_SELECT_COMPILER_INCLUDED +#endif #ifdef BOOST_MSVC + #pragma warning (push) // //'function' : resolved overload was found by argument-dependent lookup diff --git a/include/boost/intrusive/detail/ebo_holder.hpp b/include/boost/intrusive/detail/ebo_functor_holder.hpp similarity index 63% rename from include/boost/intrusive/detail/ebo_holder.hpp rename to include/boost/intrusive/detail/ebo_functor_holder.hpp index 3239a27..d58516f 100644 --- a/include/boost/intrusive/detail/ebo_holder.hpp +++ b/include/boost/intrusive/detail/ebo_functor_holder.hpp @@ -13,18 +13,18 @@ #ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP #define BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP -#include +#include namespace boost { namespace intrusive { namespace detail { -template -class ebo_holder_impl +template +class ebo_functor_holder_impl { public: - ebo_holder_impl(){} - ebo_holder_impl(const T& t):t(t){} + ebo_functor_holder_impl(){} + ebo_functor_holder_impl(const T& t):t(t){} T& get(){return t;} const T& get()const{return t;} @@ -34,29 +34,29 @@ class ebo_holder_impl }; template -class ebo_holder_impl +class ebo_functor_holder_impl : private T { public: - ebo_holder_impl(){} - ebo_holder_impl(const T& t):T(t){} + ebo_functor_holder_impl(){} + ebo_functor_holder_impl(const T& t):T(t){} T& get(){return *this;} const T& get()const{return *this;} }; template -class ebo_holder - : public ebo_holder_impl::value> +class ebo_functor_holder + : public ebo_functor_holder_impl::value> { private: - typedef ebo_holder_impl::value> super; + typedef ebo_functor_holder_impl::value> super; public: - ebo_holder(){} - ebo_holder(const T& t):super(t){} + ebo_functor_holder(){} + ebo_functor_holder(const T& t):super(t){} - ebo_holder& operator=(const ebo_holder& x) + ebo_functor_holder& operator=(const ebo_functor_holder& x) { this->get()=x.get(); return *this; diff --git a/include/boost/intrusive/detail/hashtable_node.hpp b/include/boost/intrusive/detail/hashtable_node.hpp index e2f8653..7e875cf 100644 --- a/include/boost/intrusive/detail/hashtable_node.hpp +++ b/include/boost/intrusive/detail/hashtable_node.hpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include #include #ifdef BOOST_INTRUSIVE_USE_ITERATOR_FACADE @@ -25,6 +25,7 @@ #include #include #endif +#include #include namespace boost { @@ -261,9 +262,7 @@ class hashtable_iterator #else template hashtable_iterator(hashtable_iterator const& other, - typename enable_if< - is_convertible - >::type* = 0) + typename enable_if >::type* = 0) : local_it_(other.local_it_), bucket_info_(other.bucket_info_) {} #endif diff --git a/include/boost/intrusive/detail/list_node.hpp b/include/boost/intrusive/detail/list_node.hpp index e3a67c7..03c8927 100644 --- a/include/boost/intrusive/detail/list_node.hpp +++ b/include/boost/intrusive/detail/list_node.hpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #ifdef BOOST_INTRUSIVE_USE_ITERATOR_FACADE diff --git a/include/boost/intrusive/detail/mpl.hpp b/include/boost/intrusive/detail/mpl.hpp new file mode 100644 index 0000000..821c640 --- /dev/null +++ b/include/boost/intrusive/detail/mpl.hpp @@ -0,0 +1,177 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Ion Gaztanaga 2006-2007 +// +// 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_DETAIL_MPL_HPP +#define BOOST_INTRUSIVE_DETAIL_MPL_HPP + +namespace boost { +namespace intrusive { +namespace detail { + +template< bool C_ > +struct bool_ +{ + static const bool value = C_; +}; + +typedef bool_ true_; +typedef bool_ false_; + +typedef true_ true_type; +typedef false_ false_type; + +typedef char yes_type; +struct no_type +{ + char padding[8]; +}; + +template +struct enable_if_c { + typedef T type; +}; + +template +struct enable_if_c {}; + +template +struct enable_if : public enable_if_c{}; + +template +class is_convertible +{ + typedef char true_t; + class false_t { char dummy[2]; }; + static true_t dispatch(U); + static false_t dispatch(...); + static T trigger(); + public: + enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) }; +}; + +#if defined(BOOST_MSVC) || defined(__BORLANDC_) +#define BOOST_INTRUSIVE_TT_DECL __cdecl +#else +#define BOOST_INTRUSIVE_TT_DECL +#endif + +#if defined(_MSC_EXTENSIONS) && !defined(__BORLAND__) +#define BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS +#endif + +no_type BOOST_INTRUSIVE_TT_DECL is_function_ptr_tester(...); + +template +yes_type is_function_ptr_tester(R (*)()); + +template +yes_type is_function_ptr_tester(R (*)( ...)); + +#ifdef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS +template +yes_type is_function_ptr_tester(R (__stdcall*)()); +template +yes_type is_function_ptr_tester(R (__stdcall*)( ...)); + +template +yes_type is_function_ptr_tester(R (__fastcall*)()); +template +yes_type is_function_ptr_tester(R (__fastcall*)( ...)); + +template +yes_type is_function_ptr_tester(R (__cdecl*)()); +template +yes_type is_function_ptr_tester(R (__cdecl*)( ...)); +#endif + +template +yes_type is_function_ptr_tester(R (*)( T0)); + +template +yes_type is_function_ptr_tester(R (*)( T0 ...)); + +#ifdef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS +template +yes_type is_function_ptr_tester(R (__stdcall*)( T0)); +template +yes_type is_function_ptr_tester(R (__stdcall*)( T0 ...)); + +template +yes_type is_function_ptr_tester(R (__fastcall*)( T0)); +template +yes_type is_function_ptr_tester(R (__fastcall*)( T0 ...)); + +template +yes_type is_function_ptr_tester(R (__cdecl*)( T0)); +#endif +template +yes_type is_function_ptr_tester(R (*)( T0 , T1)); + +#ifdef BOOST_INTRUSIVE_TT_TEST_MSC_FUNC_SIGS +template +yes_type is_function_ptr_tester(R (__stdcall*)( T0 , T1)); + +template +yes_type is_function_ptr_tester(R (__fastcall*)( T0 , T1)); + +template +yes_type is_function_ptr_tester(R (__cdecl*)( T0 , T1)); +#endif + +template +struct is_unary_or_binary_function_impl +{ + static T* t; + enum{ value = sizeof(is_function_ptr_tester(t)) == sizeof(yes_type) }; +}; + +template +struct is_unary_or_binary_function_impl +{ enum {value = false }; }; + +template +struct is_unary_or_binary_function +{ + enum{ value = is_unary_or_binary_function_impl::value }; +}; + +//boost::alignment_of yields to 10K lines of preprocessed code, so we +//need an alternative +template struct alignment_of; + +template +struct alignment_of_hack +{ + char c; + T t; + alignment_of_hack(); +}; + +template +struct alignment_logic +{ + enum{ value = A < S ? A : S }; +}; + +template< typename T > +struct alignment_of +{ + enum{ value = alignment_logic + < sizeof(alignment_of_hack) - sizeof(T) + , sizeof(T)>::value }; +}; + +} //namespace detail +} //namespace intrusive +} //namespace boost + +#endif //BOOST_INTRUSIVE_DETAIL_MPL_HPP diff --git a/include/boost/intrusive/detail/parent_from_member.hpp b/include/boost/intrusive/detail/parent_from_member.hpp index 6c2e945..00a592c 100644 --- a/include/boost/intrusive/detail/parent_from_member.hpp +++ b/include/boost/intrusive/detail/parent_from_member.hpp @@ -13,7 +13,7 @@ #define BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP #include - +#include namespace boost { namespace intrusive { namespace detail { @@ -22,8 +22,7 @@ template std::size_t offset_from_pointer_to_member(const Member Parent::* ptr_to_member) { //The implementation of a pointer to member is compiler dependent. - #if defined(BOOST_MSVC) || defined(__GNUC__) || \ - defined(BOOST_INTEL) || defined(__HP_aCC) + #if (defined(_MSC_VER) || defined(__GNUC__) || defined(BOOST_INTEL) || defined(__HP_aCC)) //This works with gcc, msvc, ac++ return *(const std::size_t*)(const void*)&ptr_to_member; #else diff --git a/include/boost/intrusive/detail/rbtree_node.hpp b/include/boost/intrusive/detail/rbtree_node.hpp index baf8c81..12eab42 100644 --- a/include/boost/intrusive/detail/rbtree_node.hpp +++ b/include/boost/intrusive/detail/rbtree_node.hpp @@ -26,11 +26,10 @@ #include #endif #include -#include +#include namespace boost { namespace intrusive { - namespace detail { ///////////////////////////////////////////////////////////////////////////// @@ -171,7 +170,7 @@ struct rbtree_node_traits : public rbtree_node_traits_dispatch + >::value >::value > diff --git a/include/boost/intrusive/detail/slist_node.hpp b/include/boost/intrusive/detail/slist_node.hpp index b82e895..a22c117 100644 --- a/include/boost/intrusive/detail/slist_node.hpp +++ b/include/boost/intrusive/detail/slist_node.hpp @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #ifdef BOOST_INTRUSIVE_USE_ITERATOR_FACADE diff --git a/include/boost/intrusive/detail/utilities.hpp b/include/boost/intrusive/detail/utilities.hpp index a74c8ba..8dda4cd 100644 --- a/include/boost/intrusive/detail/utilities.hpp +++ b/include/boost/intrusive/detail/utilities.hpp @@ -16,9 +16,11 @@ #include #include #include -#include +#include #include +#include #include +#include namespace boost { namespace intrusive { @@ -65,7 +67,7 @@ class equal_to_value { return t_ == t; } }; -class null_destroyer +class null_disposer { public: template @@ -155,8 +157,8 @@ struct member_value_traits typedef typename node_traits::const_node_ptr const_node_ptr; typedef typename boost::pointer_to_other::type pointer; typedef typename boost::pointer_to_other::type const_pointer; - typedef typename std::iterator_traits::reference reference; - typedef typename std::iterator_traits::reference const_reference; + typedef value_type & reference; + typedef const value_type & const_reference; enum { linking_policy = MemberHookType::linking_policy }; public: @@ -192,10 +194,10 @@ struct member_value_traits template struct key_node_ptr_compare - : private detail::ebo_holder + : private detail::ebo_functor_holder { typedef typename ValueTraits::node_ptr node_ptr; - typedef detail::ebo_holder base_t; + typedef detail::ebo_functor_holder base_t; key_node_ptr_compare(KeyValueCompare kcomp) : base_t(kcomp) {} @@ -217,10 +219,10 @@ struct key_node_ptr_compare template struct value_to_node_cloner - : private detail::ebo_holder + : private detail::ebo_functor_holder { typedef typename ValueTraits::node_ptr node_ptr; - typedef detail::ebo_holder base_t; + typedef detail::ebo_functor_holder base_t; value_to_node_cloner(F f) : base_t(f) @@ -231,12 +233,12 @@ struct value_to_node_cloner }; template -struct value_to_node_destroyer - : private detail::ebo_holder +struct value_to_node_disposer + : private detail::ebo_functor_holder { typedef typename ValueTraits::node_ptr node_ptr; - typedef detail::ebo_holder base_t; - value_to_node_destroyer(F f) + typedef detail::ebo_functor_holder base_t; + value_to_node_disposer(F f) : base_t(f) {} @@ -250,7 +252,7 @@ struct dispatcher template void destructor_impl(Container &cont, dispatcher) -{ (void)cont; BOOST_ASSERT(!cont.is_linked()); } +{ (void)cont; BOOST_INTRUSIVE_SAFE_MODE_HOOK_DESTRUCTOR_ASSERT(!cont.is_linked()); } template void destructor_impl(Container &cont, dispatcher) @@ -262,26 +264,26 @@ void destructor_impl(Container &, dispatcher) template struct node_plus_pred - : public ebo_holder + : public ebo_functor_holder , public Node { node_plus_pred() {} node_plus_pred(const Node &x, const MaybeClass &y) - : Node(x), ebo_holder(y) {} + : Node(x), ebo_functor_holder(y) {} node_plus_pred(const MaybeClass &y) - : ebo_holder(y) {} + : ebo_functor_holder(y) {} Node &first() { return *this; } const Node &first() const { return *this; } MaybeClass &second() - { return ebo_holder::get(); } + { return ebo_functor_holder::get(); } const MaybeClass &second() const - { return ebo_holder::get(); } + { return ebo_functor_holder::get(); } static node_plus_pred *this_from_node(Node *n) { return static_cast(n); } @@ -290,33 +292,6 @@ struct node_plus_pred { return static_cast(n); } }; -#ifndef BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE - -template -struct enable_if_c { - typedef T type; -}; - -template -struct enable_if_c {}; - -template -struct enable_if : public enable_if_c {}; - -template -class is_convertible -{ - typedef char true_t; - class false_t { char dummy[2]; }; - static true_t dispatch(U); - static false_t dispatch(...); - static T trigger(); - public: - enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) }; -}; - -#endif //#ifndef BOOST_INTRUSIVE_USE_ITERATOR_ENABLE_IF_CONVERTIBLE - } //namespace detail } //namespace intrusive } //namespace boost diff --git a/include/boost/intrusive/hashtable.hpp b/include/boost/intrusive/hashtable.hpp index 5c3d65d..a517f4c 100644 --- a/include/boost/intrusive/hashtable.hpp +++ b/include/boost/intrusive/hashtable.hpp @@ -17,10 +17,9 @@ #include #include #include +#include //boost -#include -#include -#include +#include #include #include //General intrusive utilities @@ -28,10 +27,10 @@ #include #include #include +#include //Implementation utilities #include #include -#include namespace boost { namespace intrusive { @@ -104,49 +103,66 @@ class hashtable ::type const_bucket_info_ptr; //User scattered boost::compressed pair to get EBO all compilers - boost::compressed_pair - - ,Equal> members_; +// boost::compressed_pair +// +// ,Equal> members_; + struct bucket_hash_t + : public detail::ebo_functor_holder + { + bucket_hash_t(const Hash & h) + : detail::ebo_functor_holder(h) + {} + bucket_info_t bucket_info; + }; + + struct bucket_hash_equal_t + : public detail::ebo_functor_holder + { + bucket_hash_equal_t(const Hash & h, const Equal &e) + : detail::ebo_functor_holder(e), bucket_hash(h) + {} + bucket_hash_t bucket_hash; + } bucket_hash_equal_; const Equal &priv_equal() const - { return members_.second(); } + { return static_cast(bucket_hash_equal_.get()); } Equal &priv_equal() - { return members_.second(); } + { return static_cast(bucket_hash_equal_.get()); } - const_bucket_info_ptr priv_bucket_info() const - { return &members_.first().first(); } + const bucket_info_t &priv_bucket_info() const + { return bucket_hash_equal_.bucket_hash.bucket_info; } - bucket_info_ptr priv_bucket_info() - { return &members_.first().first(); } + bucket_info_t &priv_bucket_info() + { return bucket_hash_equal_.bucket_hash.bucket_info; } const Hash &priv_hasher() const - { return members_.first().second(); } + { return static_cast(bucket_hash_equal_.bucket_hash.get()); } Hash &priv_hasher() - { return members_.first().second(); } + { return static_cast(bucket_hash_equal_.bucket_hash.get()); } const bucket_ptr &priv_buckets() const - { return members_.first().first().buckets_; } + { return priv_bucket_info().buckets_; } bucket_ptr &priv_buckets() - { return members_.first().first().buckets_; } + { return priv_bucket_info().buckets_; } const size_type &priv_buckets_len() const - { return members_.first().first().buckets_len_; } + { return priv_bucket_info().buckets_len_; } size_type &priv_buckets_len() - { return members_.first().first().buckets_len_; } + { return priv_bucket_info().buckets_len_; } static node_ptr uncast(const_node_ptr ptr) { return node_ptr(const_cast(detail::get_pointer(ptr))); } - static bucket_info_ptr uncast(const_bucket_info_ptr ptr) - { - return bucket_info_ptr(const_cast(detail::get_pointer(ptr))); - } +// static bucket_info_ptr uncast(const_bucket_info_ptr ptr) +// { +// return bucket_info_ptr(const_cast(detail::get_pointer(ptr))); +// } static slist_impl &bucket_to_slist(bucket_type &b) { return static_cast(b); } @@ -167,10 +183,10 @@ class hashtable , size_type buckets_len , const Hash & hasher = Hash() , const Equal &equal = Equal()) - : members_(boost::compressed_pair(hasher), equal) + : bucket_hash_equal_(hasher, equal) { - BOOST_ASSERT(buckets_len != 0); + BOOST_INTRUSIVE_INVARIANT_ASSERT(buckets_len != 0); priv_buckets() = buckets; priv_buckets_len() = buckets_len; priv_clear_buckets(); @@ -184,7 +200,7 @@ class hashtable { size_type bucket_num; local_iterator local_it = priv_begin(bucket_num); - return iterator( local_it, this->priv_bucket_info()); + return iterator(local_it, const_bucket_info_ptr(&this->priv_bucket_info())); } const_iterator begin() const @@ -194,23 +210,17 @@ class hashtable { size_type bucket_num; local_iterator local_it = priv_begin(bucket_num); - return const_iterator( local_it, this->priv_bucket_info()); + return const_iterator( local_it, const_bucket_info_ptr(&this->priv_bucket_info())); } iterator end() - { - bucket_info_t *info = detail::get_pointer(this->priv_bucket_info()); - return iterator(invalid_local_it(*info), 0); - } + { return iterator(invalid_local_it(this->priv_bucket_info()), 0); } const_iterator end() const { return cend(); } const_iterator cend() const - { - const bucket_info_t *info = detail::get_pointer(this->priv_bucket_info()); - return const_iterator(invalid_local_it(*info), 0); - } + { return const_iterator(invalid_local_it(this->priv_bucket_info()), 0); } hasher hash_function() const { return this->priv_hasher(); } @@ -266,10 +276,10 @@ class hashtable } } - template - void clone_from(const hashtable &src, Cloner cloner, Destroyer destroyer) + template + void clone_from(const hashtable &src, Cloner cloner, Disposer disposer) { - this->clear_and_destroy(destroyer); + this->clear_and_dispose(disposer); if(!ConstantTimeSize || !src.empty()){ const size_type src_bucket_count = src.bucket_count(); const size_type dst_bucket_count = this->bucket_count(); @@ -284,7 +294,7 @@ class hashtable for( constructed = 0 ; constructed < dst_bucket_count ; ++constructed){ - dst_buckets[constructed].clone_from(src_buckets[constructed], cloner, destroyer); + dst_buckets[constructed].clone_from(src_buckets[constructed], cloner, disposer); } if(src_bucket_count != dst_bucket_count){ //Now insert the remaining ones using the modulo trick @@ -303,7 +313,7 @@ class hashtable } catch(...){ while(constructed--){ - dst_buckets[constructed].clear_and_destroy(destroyer); + dst_buckets[constructed].clear_and_dispose(disposer); } throw; } @@ -319,7 +329,7 @@ class hashtable } } catch(...){ - this->clear_and_destroy(destroyer); + this->clear_and_dispose(disposer); throw; } } @@ -331,11 +341,11 @@ class hashtable size_type bucket_num, hash; local_iterator it = priv_find(value, this->priv_hasher(), this->priv_equal(), bucket_num, hash); bucket_type &b = this->priv_buckets()[bucket_num]; - if(it == invalid_local_it(*this->priv_bucket_info())){ + if(it == invalid_local_it(this->priv_bucket_info())){ it = b.before_begin(); } size_traits::increment(); - return iterator(b.insert_after(it, value), this->priv_bucket_info()); + return iterator(b.insert_after(it, value), const_bucket_info_ptr(&this->priv_bucket_info())); } template @@ -375,12 +385,12 @@ class hashtable size_type bucket_num; local_iterator prev_pos = priv_find(key, hasher, key_value_eq, bucket_num, commit_data.hash); - bool success = prev_pos == invalid_local_it(*this->priv_bucket_info()); + bool success = prev_pos == invalid_local_it(this->priv_bucket_info()); if(success){ prev_pos = this->priv_buckets()[bucket_num].before_begin(); } return std::pair - (iterator(prev_pos, this->priv_bucket_info()) + (iterator(prev_pos, const_bucket_info_ptr(&this->priv_bucket_info())) ,success); } @@ -390,34 +400,34 @@ class hashtable bucket_type &b = this->priv_buckets()[bucket_num]; size_traits::increment(); return iterator( b.insert_after(b.before_begin(), value) - , this->priv_bucket_info()); + , const_bucket_info_ptr(&this->priv_bucket_info())); } void erase(const_iterator i) - { erase_and_destroy(i, detail::null_destroyer()); } + { erase_and_dispose(i, detail::null_disposer()); } void erase(const_iterator b, const_iterator e) - { erase_and_destroy(b, e, detail::null_destroyer()); } + { erase_and_dispose(b, e, detail::null_disposer()); } size_type erase(const_reference value) { return this->erase(value, this->priv_hasher(), this->priv_equal()); } template size_type erase(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) - { return erase_and_destroy(key, hasher, equal, detail::null_destroyer()); } + { return erase_and_dispose(key, hasher, equal, detail::null_disposer()); } - template - void erase_and_destroy(const_iterator i, Destroyer destroyer) + template + void erase_and_dispose(const_iterator i, Disposer disposer) { local_iterator to_erase(i.local()); bucket_ptr f(priv_buckets()), l(f + priv_buckets_len()); bucket_type &b = this->priv_buckets()[bucket_type::get_bucket_num(to_erase, *f, *l)]; - b.erase_after_and_destroy(b.previous(to_erase), destroyer); + b.erase_after_and_dispose(b.previous(to_erase), disposer); size_traits::decrement(); } - template - void erase_and_destroy(const_iterator b, const_iterator e, Destroyer destroyer) + template + void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) { if(b == e) return; @@ -448,7 +458,7 @@ class hashtable local_iterator nxt(before_first_local_it); ++nxt; local_iterator end = first_b.end(); while(nxt != end){ - nxt = first_b.erase_after_and_destroy(before_first_local_it, destroyer); + nxt = first_b.erase_after_and_dispose(before_first_local_it, disposer); size_traits::decrement(); } } @@ -462,7 +472,7 @@ class hashtable local_iterator nxt(b_begin); ++nxt; local_iterator end = b.end(); while(nxt != end){ - nxt = b.erase_after_and_destroy(b_begin, destroyer); + nxt = b.erase_after_and_dispose(b_begin, disposer); size_traits::decrement(); } } @@ -473,19 +483,19 @@ class hashtable local_iterator b_begin(last_b.before_begin()); local_iterator nxt(b_begin); ++nxt; while(nxt != last_local_it){ - nxt = last_b.erase_after_and_destroy(b_begin, destroyer); + nxt = last_b.erase_after_and_dispose(b_begin, disposer); size_traits::decrement(); } } } - template - size_type erase_and_destroy(const_reference value, Destroyer destroyer) - { return erase_and_destroy(value, priv_hasher(), priv_equal(), destroyer); } + template + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return erase_and_dispose(value, priv_hasher(), priv_equal(), disposer); } - template - size_type erase_and_destroy(const KeyType& key, KeyHasher hasher - ,KeyValueEqual equal, Destroyer destroyer) + template + size_type erase_and_dispose(const KeyType& key, KeyHasher hasher + ,KeyValueEqual equal, Disposer disposer) { size_type count(0); @@ -513,7 +523,7 @@ class hashtable //If found erase all equal values for(local_iterator end = b.end(); it != end && equal(key, *it); ++count){ - it = b.erase_after_and_destroy(prev, destroyer); + it = b.erase_after_and_dispose(prev, disposer); size_traits::decrement(); } return count; @@ -527,14 +537,14 @@ class hashtable size_traits::set_size(size_type(0)); } - template - void clear_and_destroy(Destroyer destroyer) + template + void clear_and_dispose(Disposer disposer) { if(!ConstantTimeSize || !this->empty()){ size_type num_buckets = this->bucket_count(); bucket_ptr b = this->priv_buckets(); for(; num_buckets--; ++b){ - b->clear_and_destroy(destroyer); + b->clear_and_dispose(disposer); } size_traits::set_size(size_type(0)); } @@ -560,7 +570,7 @@ class hashtable size_type bucket_n, hash; local_iterator local_it = priv_find(key, hasher, equal, bucket_n, hash); return iterator( local_it - , this->priv_bucket_info()); + , const_bucket_info_ptr(&this->priv_bucket_info())); } const_iterator find(const_reference value) const @@ -573,7 +583,7 @@ class hashtable size_type bucket_n, hash; local_iterator local_it = priv_find(key, hasher, equal, bucket_n, hash); return const_iterator( local_it - , uncast(this->priv_bucket_info())); + , const_bucket_info_ptr(&this->priv_bucket_info())); } std::pair equal_range(const_reference value) @@ -586,9 +596,10 @@ class hashtable size_type bucket_n1, bucket_n2, count; std::pair ret = priv_equal_range(key, hasher, equal, bucket_n1, bucket_n2, count); + const_bucket_info_ptr info_ptr (&this->priv_bucket_info()); return std::pair - ( iterator( ret.first, this->priv_bucket_info() ) - , iterator( ret.second, this->priv_bucket_info()) ); + ( iterator( ret.first, info_ptr) + , iterator( ret.second, info_ptr) ); } std::pair @@ -602,9 +613,10 @@ class hashtable size_type bucket_n1, bucket_n2, count; std::pair ret = priv_equal_range(key, hasher, equal, bucket_n1, bucket_n2, count); + const_bucket_info_ptr info_ptr (&this->priv_bucket_info()); return std::pair - ( const_iterator( ret.first, uncast(this->priv_bucket_info()) ) - , const_iterator( ret.second, uncast(this->priv_bucket_info()) ) ); + ( const_iterator( ret.first, info_ptr) + , const_iterator( ret.second, info_ptr) ); } size_type bucket_count() const @@ -703,13 +715,13 @@ class hashtable iterator iterator_to(reference value) { return iterator( bucket_type::iterator_to(value) - , this->priv_bucket_info()); + , const_bucket_info_ptr(&this->priv_bucket_info())); } const_iterator iterator_to(const_reference value) const { return const_iterator( bucket_type::iterator_to(const_cast(value)) - , uncast(this->priv_bucket_info())); + , const_bucket_info_ptr(&this->priv_bucket_info())); } static local_iterator local_iterator_to(reference value) @@ -755,7 +767,7 @@ class hashtable if(!b.empty()) return b.begin(); } - return invalid_local_it(*this->priv_bucket_info()); + return invalid_local_it(this->priv_bucket_info()); } void priv_clear_buckets() @@ -778,7 +790,7 @@ class hashtable bucket_number = hash % b_len; if(ConstantTimeSize && this->empty()){ - return invalid_local_it(*this->priv_bucket_info()); + return invalid_local_it(this->priv_bucket_info()); } bucket_type &b = this->priv_buckets()[bucket_number]; @@ -791,7 +803,7 @@ class hashtable ++it; } - return invalid_local_it(*this->priv_bucket_info()); + return invalid_local_it(this->priv_bucket_info()); } template @@ -808,7 +820,7 @@ class hashtable //Let's see if the element is present std::pair to_return ( priv_find(key, hasher, equal, bucket_number_first, hash) - , invalid_local_it(*this->priv_bucket_info())); + , invalid_local_it(this->priv_bucket_info())); if(to_return.first == to_return.second){ bucket_number_second = bucket_number_first; return to_return; @@ -842,7 +854,7 @@ class hashtable } //Otherwise, return the end node - to_return.second = invalid_local_it(*this->priv_bucket_info()); + to_return.second = invalid_local_it(this->priv_bucket_info()); return to_return; } /// @endcond diff --git a/include/boost/intrusive/intrusive_fwd.hpp b/include/boost/intrusive/intrusive_fwd.hpp index 8f7c103..07f624b 100644 --- a/include/boost/intrusive/intrusive_fwd.hpp +++ b/include/boost/intrusive/intrusive_fwd.hpp @@ -14,7 +14,6 @@ #define BOOST_INTRUSIVE_FWD_HPP #include -#include #include #include @@ -30,6 +29,11 @@ struct less; } //namespace std{ namespace boost { + +//Hash predeclaration +template +struct hash; + namespace intrusive { //////////////////////////// diff --git a/include/boost/intrusive/list.hpp b/include/boost/intrusive/list.hpp index c6435cd..56e5b60 100644 --- a/include/boost/intrusive/list.hpp +++ b/include/boost/intrusive/list.hpp @@ -15,8 +15,7 @@ #define BOOST_INTRUSIVE_LIST_HPP #include -#include -#include +#include #include #include #include @@ -165,7 +164,7 @@ class list { node_ptr to_insert = ValueTraits::to_node_ptr(value); if(safemode_or_autounlink) - BOOST_ASSERT(node_algorithms::unique(to_insert)); + BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT(node_algorithms::unique(to_insert)); node_algorithms::link_before(this->get_root_node(), to_insert); size_traits::increment(); } @@ -184,7 +183,7 @@ class list { node_ptr to_insert = ValueTraits::to_node_ptr(value); if(safemode_or_autounlink) - BOOST_ASSERT(node_algorithms::unique(to_insert)); + BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT(node_algorithms::unique(to_insert)); node_algorithms::link_before(node_traits::get_next(this->get_root_node()), to_insert); size_traits::increment(); } @@ -206,26 +205,26 @@ class list node_algorithms::init(to_erase); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the last element of the list. //! No destructors are called. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Throws: Nothing. //! //! Complexity: Constant. //! //! Note: Invalidates the iterators to the erased element. - template - void pop_back_and_destroy(Destroyer destroyer) + template + void pop_back_and_dispose(Disposer disposer) { node_ptr to_erase = node_traits::get_previous(this->get_root_node()); node_algorithms::unlink(to_erase); size_traits::decrement(); if(safemode_or_autounlink) node_algorithms::init(to_erase); - destroyer(ValueTraits::to_value_ptr(to_erase)); + disposer(ValueTraits::to_value_ptr(to_erase)); } //! Effects: Erases the first element of the list. @@ -245,26 +244,26 @@ class list node_algorithms::init(to_erase); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the first element of the list. //! No destructors are called. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Throws: Nothing. //! //! Complexity: Constant. //! //! Note: Invalidates the iterators to the erased element. - template - void pop_front_and_destroy(Destroyer destroyer) + template + void pop_front_and_dispose(Disposer disposer) { node_ptr to_erase = node_traits::get_next(this->get_root_node()); node_algorithms::unlink(to_erase); size_traits::decrement(); if(safemode_or_autounlink) node_algorithms::init(to_erase); - destroyer(ValueTraits::to_value_ptr(to_erase)); + disposer(ValueTraits::to_value_ptr(to_erase)); } //! Effects: Returns a reference to the first element of the list. @@ -570,11 +569,11 @@ class list } } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the element pointed by i of the list. //! No destructors are called. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Returns: the first element remaining beyond the removed element, //! or end() if no such element exists. @@ -584,8 +583,8 @@ class list //! Complexity: Constant. //! //! Note: Invalidates the iterators to the erased element. - template - iterator erase_and_destroy(iterator i, Destroyer destroyer) + template + iterator erase_and_dispose(iterator i, Disposer disposer) { iterator erase = i; ++i; @@ -594,15 +593,15 @@ class list size_traits::decrement(); if(safemode_or_autounlink) node_algorithms::init(to_erase); - destroyer(ValueTraits::to_value_ptr(to_erase)); + disposer(ValueTraits::to_value_ptr(to_erase)); return i; } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the element range pointed by b and e //! No destructors are called. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: the first element remaining beyond the removed elements, //! or end() if no such element exists. @@ -612,11 +611,11 @@ class list //! Complexity: Linear to the number of elements erased. //! //! Note: Invalidates the iterators to the erased elements. - template - iterator erase_and_destroy(iterator b, iterator e, Destroyer destroyer) + template + iterator erase_and_dispose(iterator b, iterator e, Disposer disposer) { while(b != e){ - b = this->erase_and_destroy(b, destroyer); + b = this->erase_and_dispose(b, disposer); } return b; } @@ -641,38 +640,38 @@ class list } } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements of the container. //! No destructors are called. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Throws: Nothing. //! //! Complexity: Linear to the number of elements of the list. //! //! Note: Invalidates the iterators to the erased elements. - template - void clear_and_destroy(Destroyer destroyer) - { this->erase_and_destroy(this->begin(), this->end(), destroyer); } + template + void clear_and_dispose(Disposer disposer) + { this->erase_and_dispose(this->begin(), this->end(), disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements from *this - //! calling Destroyer::operator()(pointer), clones all the + //! calling Disposer::operator()(pointer), clones all the //! elements from src calling Cloner::operator()(const_reference ) //! and inserts them on *this. //! - //! If cloner throws, all cloned elements are unlinked and destroyed - //! calling Destroyer::operator()(pointer). + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). //! //! Complexity: Linear to erased plus inserted elements. //! //! Throws: If cloner throws. Basic guarantee. - template - void clone_from(const list &src, Cloner cloner, Destroyer destroyer) + template + void clone_from(const list &src, Cloner cloner, Disposer disposer) { - this->clear_and_destroy(destroyer); + this->clear_and_dispose(disposer); try{ const_iterator b(src.begin()), e(src.end()); for(; b != e; ++b){ @@ -680,7 +679,7 @@ class list } } catch(...){ - clear_and_destroy(destroyer); + clear_and_dispose(disposer); throw; } } @@ -700,7 +699,7 @@ class list { node_ptr to_insert = ValueTraits::to_node_ptr(value); if(safemode_or_autounlink) - BOOST_ASSERT(node_algorithms::unique(to_insert)); + BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT(node_algorithms::unique(to_insert)); node_algorithms::link_before(p.pointed_node(), to_insert); size_traits::increment(); return iterator(to_insert); @@ -746,14 +745,14 @@ class list this->insert(this->end(), b, e); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Requires: Dereferencing iterator must yield //! an lvalue of type value_type. //! //! Effects: Clears the list and inserts the range pointed by b and e. //! No destructors or copy constructors are called. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Throws: Nothing. //! @@ -762,10 +761,10 @@ class list //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. - template - void destroy_and_assign(Destroyer destroyer, Iterator b, Iterator e) + template + void dispose_and_assign(Disposer disposer, Iterator b, Iterator e) { - this->clear(destroyer); + this->clear(disposer); this->insert(this->end(), b, e); } @@ -855,7 +854,7 @@ class list { if(n){ if(ConstantTimeSize){ - BOOST_ASSERT(n == std::distance(start, end)); + BOOST_INTRUSIVE_INVARIANT_ASSERT(n == std::distance(start, end)); node_algorithms::transfer(p.pointed_node(), start.pointed_node(), end.pointed_node()); size_traits::set_size(size_traits::get_size() + n); x.set_size(x.get_size() - n); @@ -989,10 +988,10 @@ class list void remove(const_reference value) { remove_if(detail::equal_to_value(value)); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Removes all the elements that compare equal to value. - //! Destroyer::operator()(pointer) is called for every removed element. + //! Disposer::operator()(pointer) is called for every removed element. //! //! Throws: If std::equal_to throws. Basic guarantee. //! @@ -1000,9 +999,9 @@ class list //! //! Note: The relative order of elements that are not removed is unchanged, //! and iterators to elements that are not removed remain valid. - template - void remove_and_destroy(const_reference value, Destroyer destroyer) - { remove_and_destroy_if(detail::equal_to_value(value), destroyer); } + template + void remove_and_dispose(const_reference value, Disposer disposer) + { remove_and_dispose_if(detail::equal_to_value(value), disposer); } //! Effects: Removes all the elements for which a specified //! predicate is satisfied. No destructors are called. @@ -1015,13 +1014,13 @@ class list //! and iterators to elements that are not removed remain valid. template void remove_if(Pred pred) - { remove_and_destroy_if(pred, detail::null_destroyer()); } + { remove_and_dispose_if(pred, detail::null_disposer()); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Removes all the elements for which a specified //! predicate is satisfied. - //! Destroyer::operator()(pointer) is called for every removed element. + //! Disposer::operator()(pointer) is called for every removed element. //! //! Throws: If pred throws. Basic guarantee. //! @@ -1029,8 +1028,8 @@ class list //! //! Note: The relative order of elements that are not removed is unchanged, //! and iterators to elements that are not removed remain valid. - template - void remove_and_destroy_if(Pred pred, Destroyer destroyer) + template + void remove_and_dispose_if(Pred pred, Disposer disposer) { iterator first = begin(); iterator last = end(); @@ -1040,7 +1039,7 @@ class list if(pred(*first)){ pointer p = first.operator->(); this->erase(first); - destroyer(p); + disposer(p); } first = next; } @@ -1056,7 +1055,7 @@ class list //! Note: The relative order of elements that are not removed is unchanged, //! and iterators to elements that are not removed remain valid. void unique() - { unique_and_destroy(std::equal_to(), detail::null_destroyer()); } + { unique_and_dispose(std::equal_to(), detail::null_disposer()); } //! Effects: Removes adjacent duplicate elements or adjacent //! elements that satisfy some binary predicate from the list. @@ -1070,13 +1069,13 @@ class list //! and iterators to elements that are not removed remain valid. template void unique(BinaryPredicate pred) - { unique_and_destroy(pred, detail::null_destroyer()); } + { unique_and_dispose(pred, detail::null_disposer()); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Removes adjacent duplicate elements or adjacent //! elements that are equal from the list. - //! Destroyer::operator()(pointer) is called for every removed element. + //! Disposer::operator()(pointer) is called for every removed element. //! //! Throws: If std::equal_toNote: The relative order of elements that are not removed is unchanged, //! and iterators to elements that are not removed remain valid. - template - void unique_and_destroy(Destroyer destroyer) - { unique_and_destroy(std::equal_to(), destroyer); } + template + void unique_and_dispose(Disposer disposer) + { unique_and_dispose(std::equal_to(), disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Removes adjacent duplicate elements or adjacent //! elements that satisfy some binary predicate from the list. - //! Destroyer::operator()(pointer) is called for every removed element. + //! Disposer::operator()(pointer) is called for every removed element. //! //! Throws: If pred throws. Basic guarantee. //! @@ -1100,8 +1099,8 @@ class list //! //! Note: The relative order of elements that are not removed is unchanged, //! and iterators to elements that are not removed remain valid. - template - void unique_and_destroy(BinaryPredicate pred, Destroyer destroyer) + template + void unique_and_dispose(BinaryPredicate pred, Disposer disposer) { if(!this->empty()){ iterator first = begin(); @@ -1111,7 +1110,7 @@ class list if(pred(*first, *after)){ pointer p = after.operator->(); after = erase(after); - destroyer(p); + disposer(p); } else{ first = after++; @@ -1131,7 +1130,7 @@ class list //! Note: Iterators and references are not invalidated. static iterator iterator_to(reference value) { - BOOST_ASSERT(!node_algorithms::unique(ValueTraits::to_node_ptr(value))); + BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::unique(ValueTraits::to_node_ptr(value))); return iterator(ValueTraits::to_node_ptr(value)); } @@ -1146,7 +1145,7 @@ class list //! Note: Iterators and references are not invalidated. static const_iterator iterator_to(const_reference value) { - BOOST_ASSERT(!node_algorithms::unique(ValueTraits::to_node_ptr(const_cast (value)))); + BOOST_INTRUSIVE_INVARIANT_ASSERT(!node_algorithms::unique(ValueTraits::to_node_ptr(const_cast (value)))); return const_iterator(ValueTraits::to_node_ptr(const_cast (value))); } }; diff --git a/include/boost/intrusive/list_hook.hpp b/include/boost/intrusive/list_hook.hpp index 19ac691..992fde4 100644 --- a/include/boost/intrusive/list_hook.hpp +++ b/include/boost/intrusive/list_hook.hpp @@ -23,7 +23,6 @@ #include #include #include -#include namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/rbtree.hpp b/include/boost/intrusive/rbtree.hpp index 4aac287..ffcd08e 100644 --- a/include/boost/intrusive/rbtree.hpp +++ b/include/boost/intrusive/rbtree.hpp @@ -15,15 +15,14 @@ #include #include #include -#include #include -#include +#include #include #include #include #include #include -#include +#include #include #include #include @@ -353,7 +352,7 @@ class rbtree detail::key_node_ptr_compare key_node_comp(priv_comp()); node_ptr to_insert(ValueTraits::to_node_ptr(value)); if(safemode_or_autounlink) - BOOST_ASSERT(node_algorithms::unique(to_insert)); + BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT(node_algorithms::unique(to_insert)); size_traits::increment(); return iterator(node_algorithms::insert_equal_upper_bound (node_ptr(&priv_header()), to_insert, key_node_comp)); @@ -375,7 +374,7 @@ class rbtree detail::key_node_ptr_compare key_node_comp(priv_comp()); node_ptr to_insert(ValueTraits::to_node_ptr(value)); if(safemode_or_autounlink) - BOOST_ASSERT(node_algorithms::unique(to_insert)); + BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT(node_algorithms::unique(to_insert)); size_traits::increment(); return iterator(node_algorithms::insert_equal_lower_bound (node_ptr(&priv_header()), to_insert, key_node_comp)); @@ -400,7 +399,7 @@ class rbtree detail::key_node_ptr_compare key_node_comp(priv_comp()); node_ptr to_insert(ValueTraits::to_node_ptr(value)); if(safemode_or_autounlink) - BOOST_ASSERT(node_algorithms::unique(to_insert)); + BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT(node_algorithms::unique(to_insert)); size_traits::increment(); return iterator(node_algorithms::insert_equal (node_ptr(&priv_header()), hint.pointed_node(), to_insert, key_node_comp)); @@ -540,7 +539,7 @@ class rbtree { node_ptr to_insert(ValueTraits::to_node_ptr(value)); if(safemode_or_autounlink) - BOOST_ASSERT(node_algorithms::unique(to_insert)); + BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT(node_algorithms::unique(to_insert)); size_traits::increment(); node_algorithms::insert_unique_commit (node_ptr(&priv_header()), to_insert, commit_data); @@ -561,7 +560,7 @@ class rbtree ++ret; node_ptr to_erase(i.pointed_node()); if(safemode_or_autounlink) - BOOST_ASSERT(!node_algorithms::unique(to_erase)); + BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT(!node_algorithms::unique(to_erase)); node_algorithms::erase(&priv_header(), to_erase); size_traits::decrement(); if(safemode_or_autounlink) @@ -614,10 +613,10 @@ class rbtree return n; } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the element pointed to by pos. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Complexity: Average complexity for erase element is constant time. //! @@ -625,19 +624,19 @@ class rbtree //! //! Note: Invalidates the iterators //! to the erased elements. - template - iterator erase_and_destroy(iterator i, Destroyer destroyer) + template + iterator erase_and_dispose(iterator i, Disposer disposer) { node_ptr to_erase(i.pointed_node()); iterator ret(this->erase(i)); - destroyer(ValueTraits::to_value_ptr(to_erase)); + disposer(ValueTraits::to_value_ptr(to_erase)); return ret; } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the range pointed to by b end e. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Complexity: Average complexity for erase range is at most //! O(log(size() + N)), where N is the number of elements in the range. @@ -646,14 +645,14 @@ class rbtree //! //! Note: Invalidates the iterators //! to the erased elements. - template - iterator erase_and_destroy(iterator b, iterator e, Destroyer destroyer) - { size_type n; return private_erase(b, e, n, destroyer); } + template + iterator erase_and_dispose(iterator b, iterator e, Disposer disposer) + { size_type n; return private_erase(b, e, n, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given value. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: The number of erased elements. //! @@ -663,20 +662,20 @@ class rbtree //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. No destructors are called. - template - size_type erase_and_destroy(const_reference value, Destroyer destroyer) + template + size_type erase_and_dispose(const_reference value, Disposer disposer) { std::pair p = this->equal_range(value); size_type n; - private_erase(p.first, p.second, n, destroyer); + private_erase(p.first, p.second, n, disposer); return n; } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given key. //! according to the comparison functor "comp". - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: The number of erased elements. //! @@ -686,12 +685,12 @@ class rbtree //! //! Note: Invalidates the iterators //! to the erased elements. - template - size_type erase_and_destroy(const KeyType& key, KeyValueCompare comp, Destroyer destroyer) + template + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer) { std::pair p = this->equal_range(key, comp); size_type n; - private_erase(p.first, p.second, n, destroyer); + private_erase(p.first, p.second, n, disposer); return n; } @@ -724,7 +723,7 @@ class rbtree } } - //! Effects: Erases all of the elements calling destroyer(p) for + //! Effects: Erases all of the elements calling disposer(p) for //! each node to be erased. //! Complexity: Average complexity for is at most O(log(size() + N)), //! where N is the number of elements in the container. @@ -732,9 +731,9 @@ class rbtree //! Throws: Nothing. //! //! Note: Invalidates the iterators (but not the references) - //! to the erased elements. Calls N times to destroyer functor. - template - void clear_and_destroy(Destroyer destroyer) + //! to the erased elements. Calls N times to disposer functor. + template + void clear_and_dispose(Disposer disposer) { while(1){ node_ptr leftmost @@ -745,7 +744,7 @@ class rbtree size_traits::decrement(); if(safemode_or_autounlink) node_algorithms::init(leftmost); - destroyer(ValueTraits::to_value_ptr(leftmost)); + disposer(ValueTraits::to_value_ptr(leftmost)); } } @@ -965,30 +964,30 @@ class rbtree return std::pair(const_iterator(ret.first), const_iterator(ret.second)); } - template - void clone_from(const rbtree &src, Cloner cloner, Destroyer destroyer) + template + void clone_from(const rbtree &src, Cloner cloner, Disposer disposer) { - this->clear_and_destroy(destroyer); + this->clear_and_dispose(disposer); if(!src.empty()){ node_algorithms::clone_tree (const_node_ptr(&src.priv_header()) ,node_ptr(&this->priv_header()) ,detail::value_to_node_cloner(cloner) - ,detail::value_to_node_destroyer(destroyer)); + ,detail::value_to_node_disposer(disposer)); size_traits::set_size(src.get_size()); } } pointer unlink_leftmost_without_rebalance() { - node_ptr to_destroy(node_algorithms::unlink_leftmost_without_rebalance + node_ptr to_be_disposed(node_algorithms::unlink_leftmost_without_rebalance (node_ptr(&priv_header()))); - if(!to_destroy) + if(!to_be_disposed) return 0; size_traits::decrement(); if(safemode_or_autounlink) - node_algorithms::init(to_destroy); - return ValueTraits::to_value_ptr(to_destroy); + node_algorithms::init(to_be_disposed); + return ValueTraits::to_value_ptr(to_be_disposed); } //! Requires: value must be an lvalue and shall be in a set of @@ -1059,11 +1058,11 @@ class rbtree */ /// @cond private: - template - iterator private_erase(iterator b, iterator e, size_type &n, Destroyer destroyer) + template + iterator private_erase(iterator b, iterator e, size_type &n, Disposer disposer) { for(n = 0; b != e; ++n) - this->erase_and_destroy(b++, destroyer); + this->erase_and_dispose(b++, disposer); return b; } diff --git a/include/boost/intrusive/rbtree_algorithms.hpp b/include/boost/intrusive/rbtree_algorithms.hpp index cd27731..6db298c 100644 --- a/include/boost/intrusive/rbtree_algorithms.hpp +++ b/include/boost/intrusive/rbtree_algorithms.hpp @@ -40,11 +40,11 @@ #define BOOST_INTRUSIVE_RBTREE_ALGORITHMS_HPP #include -#include +#include #include #include #include -#include +#include namespace boost { @@ -113,6 +113,16 @@ class rbtree_algorithms typedef typename NodeTraits::const_node_ptr const_node_ptr; typedef typename NodeTraits::color color; + /// @cond + private: + static node_ptr uncast(const_node_ptr ptr) + { + return node_ptr(const_cast(::boost::intrusive::detail::get_pointer(ptr))); + } + /// @endcond + + public: + //! This type is the information that will be filled by insert_unique_check struct insert_commit_data { @@ -479,30 +489,30 @@ class rbtree_algorithms } //! Requires: "cloner" must be a function - //! object taking a node_ptr and returning a new cloned node of it. "destroyer" must + //! object taking a node_ptr and returning a new cloned node of it. "disposer" must //! take a node_ptr and shouldn't throw. //! //! Effects: First empties target tree calling - //! void destroyer::operator()(node_ptr) for every node of the tree + //! void disposer::operator()(node_ptr) for every node of the tree //! except the header. //! //! Then, duplicates the entire tree pointed by "source_header" cloning each //! source node with node_ptr Cloner::operator()(node_ptr) to obtain //! the nodes of the target tree. If "cloner" throws, the cloned target nodes - //! are destroyed using void destroyer(node_ptr). + //! are disposed using void disposer(node_ptr). //! //! Complexity: Linear to the number of element of the source tree plus the. //! number of elements of tree target tree when calling this function. //! - //! Throws: If cloner functor throws. If this happens target nodes are destroyed. - template + //! Throws: If cloner functor throws. If this happens target nodes are disposed. + template static void clone_tree - (const_node_ptr source_header, node_ptr target_header, Cloner cloner, Destroyer destroyer) + (const_node_ptr source_header, node_ptr target_header, Cloner cloner, Disposer disposer) { if(!unique(target_header)){ node_ptr p; while((p = unlink_leftmost_without_rebalance(target_header))){ - destroyer(p); + disposer(p); } } @@ -512,7 +522,7 @@ class rbtree_algorithms NodeTraits::set_parent ( target_header - , deep_clone_node(source_root, target_header, cloner, destroyer)); + , deep_clone_node(source_root, target_header, cloner, disposer)); NodeTraits::set_left(target_header, minimum(NodeTraits::get_parent(target_header))); NodeTraits::set_right(target_header, maximum(NodeTraits::get_parent(target_header))); } @@ -904,16 +914,11 @@ class rbtree_algorithms (node_ptr header, node_ptr new_value, const insert_commit_data &commit_data) { //Check if commit_data has not been initialized by a insert_unique_check call. - BOOST_ASSERT(commit_data.node != 0); + BOOST_INTRUSIVE_INVARIANT_ASSERT(commit_data.node != 0); link_and_balance(new_value, commit_data.node, commit_data.link_left, header); } /// @cond - private: - static node_ptr uncast(const_node_ptr ptr) - { - return node_ptr(const_cast(detail::get_pointer(ptr))); - } //! Requires: z is the node to be inserted, par is its parent, //! left, indicates if z should be a left node of par and header is the header @@ -1100,9 +1105,9 @@ class rbtree_algorithms NodeTraits::set_color(NodeTraits::get_parent(header), NodeTraits::black()); } - template + template static node_ptr deep_clone_node - (node_ptr source_root, node_ptr new_parent, Cloner cloner, Destroyer destroyer) + (node_ptr source_root, node_ptr new_parent, Cloner cloner, Disposer disposer) { // structural copy. source_root and new_parent must be non-null. node_ptr top = cloner(source_root); @@ -1112,7 +1117,7 @@ class rbtree_algorithms if(NodeTraits::get_right(source_root)){ NodeTraits::set_right (top, deep_clone_node(NodeTraits::get_right(source_root), top - ,cloner, destroyer)); + ,cloner, disposer)); } new_parent = top; source_root = NodeTraits::get_left(source_root); @@ -1124,28 +1129,28 @@ class rbtree_algorithms if(NodeTraits::get_right(source_root)){ NodeTraits::set_right(y, deep_clone_node(NodeTraits::get_right(source_root), y - ,cloner, destroyer)); + ,cloner, disposer)); } new_parent = y; source_root = NodeTraits::get_left(source_root); } } BOOST_CATCH(...){ - deep_destroy_node(top, destroyer); + deep_dispose_node(top, disposer); BOOST_RETHROW; } BOOST_CATCH_END return top; } - template - static void deep_destroy_node(node_ptr x, Destroyer destroyer) + template + static void deep_dispose_node(node_ptr x, Disposer disposer) { // erase without rebalancing while(x){ - deep_destroy_node(NodeTraits::get_right(x), destroyer); + deep_dispose_node(NodeTraits::get_right(x), disposer); node_ptr y = NodeTraits::get_left(x); - destroyer(x); + disposer(x); x = y; } } diff --git a/include/boost/intrusive/set.hpp b/include/boost/intrusive/set.hpp index 2a189b6..b902dce 100644 --- a/include/boost/intrusive/set.hpp +++ b/include/boost/intrusive/set.hpp @@ -296,22 +296,22 @@ class set void swap(set& other) { tree_.swap(other.tree_); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements from *this - //! calling Destroyer::operator()(pointer), clones all the + //! calling Disposer::operator()(pointer), clones all the //! elements from src calling Cloner::operator()(const_reference ) //! and inserts them on *this. //! - //! If cloner throws, all cloned elements are unlinked and destroyed - //! calling Destroyer::operator()(pointer). + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). //! //! Complexity: Linear to erased plus inserted elements. //! //! Throws: If cloner throws. - template - void clone_from(const set &src, Cloner cloner, Destroyer destroyer) - { tree_.clone_from(src.tree_, cloner, destroyer); } + template + void clone_from(const set &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } //! Requires: value must be an lvalue //! @@ -516,10 +516,10 @@ class set size_type erase(const KeyType& key, KeyValueCompare comp) { return tree_.erase(key, comp); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the element pointed to by pos. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Complexity: Average complexity for erase element is constant time. //! @@ -529,14 +529,14 @@ class set //! //! Note: Invalidates the iterators //! to the erased elements. - template - iterator erase_and_destroy(iterator i, Destroyer destroyer) - { return tree_.erase_and_destroy(i, destroyer); } + template + iterator erase_and_dispose(iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the range pointed to by b end e. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Complexity: Average complexity for erase range is at most //! O(log(size() + N)), where N is the number of elements in the range. @@ -547,14 +547,14 @@ class set //! //! Note: Invalidates the iterators //! to the erased elements. - template - iterator erase_and_destroy(iterator b, iterator e, Destroyer destroyer) - { return tree_.erase_and_destroy(b, e, destroyer); } + template + iterator erase_and_dispose(iterator b, iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given value. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Throws: If the internal Compare ordering function throws. //! @@ -564,15 +564,15 @@ class set //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. No destructors are called. - template - size_type erase_and_destroy(const_reference value, Destroyer destroyer) - { return tree_.erase_and_destroy(value, destroyer); } + template + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given key. //! according to the comparison functor "comp". - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: The number of erased elements. //! @@ -582,9 +582,9 @@ class set //! //! Note: Invalidates the iterators //! to the erased elements. - template - size_type erase_and_destroy(const KeyType& key, KeyValueCompare comp, Destroyer destroyer) - { return tree_.erase_and_destroy(key, comp, destroyer); } + template + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer) + { return tree_.erase_and_dispose(key, comp, disposer); } //! Effects: Erases all the elements of the container. //! @@ -598,20 +598,20 @@ class set void clear() { return tree_.clear(); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements of the container. //! //! Complexity: Linear to the number of elements on the container. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Throws: Nothing. //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. No destructors are called. - template - void clear_and_destroy(Destroyer destroyer) - { return tree_.clear_and_destroy(destroyer); } + template + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } //! Effects: Returns the number of contained elements with the given key //! @@ -1188,22 +1188,22 @@ class multiset void swap(multiset& other) { tree_.swap(other.tree_); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements from *this - //! calling Destroyer::operator()(pointer), clones all the + //! calling Disposer::operator()(pointer), clones all the //! elements from src calling Cloner::operator()(const_reference ) //! and inserts them on *this. //! - //! If cloner throws, all cloned elements are unlinked and destroyed - //! calling Destroyer::operator()(pointer). + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). //! //! Complexity: Linear to erased plus inserted elements. //! //! Throws: If cloner throws. Basic guarantee. - template - void clone_from(const multiset &src, Cloner cloner, Destroyer destroyer) - { tree_.clone_from(src.tree_, cloner, destroyer); } + template + void clone_from(const multiset &src, Cloner cloner, Disposer disposer) + { tree_.clone_from(src.tree_, cloner, disposer); } //! Requires: value must be an lvalue //! @@ -1315,12 +1315,12 @@ class multiset size_type erase(const KeyType& key, KeyValueCompare comp) { return tree_.erase(key, comp); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Returns: An iterator to the element after the erased element. //! //! Effects: Erases the element pointed to by pos. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Complexity: Average complexity for erase element is constant time. //! @@ -1328,16 +1328,16 @@ class multiset //! //! Note: Invalidates the iterators //! to the erased elements. - template - iterator erase_and_destroy(iterator i, Destroyer destroyer) - { return tree_.erase_and_destroy(i, destroyer); } + template + iterator erase_and_dispose(iterator i, Disposer disposer) + { return tree_.erase_and_dispose(i, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Returns: An iterator to the element after the erased elements. //! //! Effects: Erases the range pointed to by b end e. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Complexity: Average complexity for erase range is at most //! O(log(size() + N)), where N is the number of elements in the range. @@ -1346,14 +1346,14 @@ class multiset //! //! Note: Invalidates the iterators //! to the erased elements. - template - iterator erase_and_destroy(iterator b, iterator e, Destroyer destroyer) - { return tree_.erase_and_destroy(b, e, destroyer); } + template + iterator erase_and_dispose(iterator b, iterator e, Disposer disposer) + { return tree_.erase_and_dispose(b, e, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given value. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: The number of erased elements. //! @@ -1363,15 +1363,15 @@ class multiset //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. No destructors are called. - template - size_type erase_and_destroy(const_reference value, Destroyer destroyer) - { return tree_.erase_and_destroy(value, destroyer); } + template + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return tree_.erase_and_dispose(value, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given key. //! according to the comparison functor "comp". - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: The number of erased elements. //! @@ -1381,9 +1381,9 @@ class multiset //! //! Note: Invalidates the iterators //! to the erased elements. - template - size_type erase_and_destroy(const KeyType& key, KeyValueCompare comp, Destroyer destroyer) - { return tree_.erase_and_destroy(key, comp, destroyer); } + template + size_type erase_and_dispose(const KeyType& key, KeyValueCompare comp, Disposer disposer) + { return tree_.erase_and_dispose(key, comp, disposer); } //! Effects: Erases all the elements of the container. //! @@ -1397,20 +1397,20 @@ class multiset void clear() { return tree_.clear(); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements of the container. //! //! Complexity: Linear to the number of elements on the container. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Throws: Nothing. //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. No destructors are called. - template - void clear_and_destroy(Destroyer destroyer) - { return tree_.clear_and_destroy(destroyer); } + template + void clear_and_dispose(Disposer disposer) + { return tree_.clear_and_dispose(disposer); } //! Effects: Returns the number of contained elements with the same key //! compared with the given comparison functor. diff --git a/include/boost/intrusive/set_hook.hpp b/include/boost/intrusive/set_hook.hpp index f7842c1..2a270cd 100644 --- a/include/boost/intrusive/set_hook.hpp +++ b/include/boost/intrusive/set_hook.hpp @@ -23,7 +23,6 @@ #include #include #include -#include namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/slist.hpp b/include/boost/intrusive/slist.hpp index ffdaacc..a4556ba 100644 --- a/include/boost/intrusive/slist.hpp +++ b/include/boost/intrusive/slist.hpp @@ -15,16 +15,14 @@ #define BOOST_INTRUSIVE_SLIST_HPP #include -#include #include -#include -#include +#include #include #include #include #include #include -#include +#include #include namespace boost { @@ -187,19 +185,19 @@ class slist } } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements of the container - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Throws: Nothing. //! //! Complexity: Linear to the number of elements of the list. //! //! Note: Invalidates the iterators to the erased elements. - template - void clear_and_destroy(Destroyer destroyer) - { this->erase_after_and_destroy(this->before_begin(), this->end(), destroyer); } + template + void clear_and_dispose(Disposer disposer) + { this->erase_after_and_dispose(this->before_begin(), this->end(), disposer); } //! Requires: value must be an lvalue. //! @@ -215,7 +213,7 @@ class slist { node_ptr to_insert = ValueTraits::to_node_ptr(value); if(safemode_or_autounlink) - BOOST_ASSERT(node_algorithms::unique(to_insert)); + BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT(node_algorithms::unique(to_insert)); node_algorithms::link_after(this->get_root_node(), to_insert); size_traits::increment(); } @@ -237,22 +235,22 @@ class slist node_algorithms::init(to_erase); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the first element of the list. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Throws: Nothing. //! //! Complexity: Constant. //! //! Note: Invalidates the iterators to the erased element. - template - void pop_front_and_destroy(Destroyer destroyer) + template + void pop_front_and_dispose(Disposer disposer) { node_ptr to_erase = node_traits::get_next(this->get_root_node()); this->pop_front(); - destroyer(ValueTraits::to_value_ptr(to_erase)); + disposer(ValueTraits::to_value_ptr(to_erase)); } //! Effects: Returns a reference to the first element of the list. @@ -511,23 +509,23 @@ class slist node_algorithms::link_after(new_last, root); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements from *this - //! calling Destroyer::operator()(pointer), clones all the + //! calling Disposer::operator()(pointer), clones all the //! elements from src calling Cloner::operator()(const_reference ) //! and inserts them on *this. //! - //! If cloner throws, all cloned elements are unlinked and destroyed - //! calling Destroyer::operator()(pointer). + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). //! //! Complexity: Linear to erased plus inserted elements. //! //! Throws: If cloner throws. - template - void clone_from(const slist &src, Cloner cloner, Destroyer destroyer) + template + void clone_from(const slist &src, Cloner cloner, Disposer disposer) { - this->clear_and_destroy(destroyer); + this->clear_and_dispose(disposer); try{ iterator prev = this->before_begin(); const_iterator b(src.begin()), e(src.end()); @@ -536,7 +534,7 @@ class slist } } catch(...){ - clear_and_destroy(destroyer); + clear_and_dispose(disposer); throw; } } @@ -558,7 +556,7 @@ class slist { node_ptr n = ValueTraits::to_node_ptr(value); if(safemode_or_autounlink) - BOOST_ASSERT(node_algorithms::unique(n)); + BOOST_INTRUSIVE_SAFE_MODE_CONTAINER_INSERTION_ASSERT(node_algorithms::unique(n)); node_algorithms::link_after(prev_p.pointed_node(), n); size_traits::increment(); return iterator (n); @@ -692,11 +690,11 @@ class slist iterator erase(iterator first, iterator last) { return erase_after(this->previous(first), last); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the element after the element pointed by prev of //! the list. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Returns: the first element remaining beyond the removed elements, //! or end() if no such element exists. @@ -706,21 +704,21 @@ class slist //! Complexity: Constant. //! //! Note: Invalidates the iterators to the erased element. - template - iterator erase_after_and_destroy(iterator prev, Destroyer destroyer) + template + iterator erase_after_and_dispose(iterator prev, Disposer disposer) { iterator it(prev); ++it; node_ptr to_erase(it.pointed_node()); iterator ret(this->erase_after(prev)); - destroyer(ValueTraits::to_value_ptr(to_erase)); + disposer(ValueTraits::to_value_ptr(to_erase)); return ret; } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the range (before_first, last) from //! the list. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: the first element remaining beyond the removed elements, //! or end() if no such element exists. @@ -730,21 +728,21 @@ class slist //! Complexity: Lineal to the elements (last - before_first). //! //! Note: Invalidates the iterators to the erased element. - template - iterator erase_after_and_destroy(iterator before_first, iterator last, Destroyer destroyer) + template + iterator erase_after_and_dispose(iterator before_first, iterator last, Disposer disposer) { iterator first; while(++(first = before_first) != last){ - this->erase_after_and_destroy(before_first, destroyer); + this->erase_after_and_dispose(before_first, disposer); } return last; } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the element pointed by i of the list. //! No destructors are called. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Returns: the first element remaining beyond the removed element, //! or end() if no such element exists. @@ -755,16 +753,16 @@ class slist //! //! Note: Invalidates the iterators (but not the references) to the //! erased element. - template - iterator erase_and_destroy(iterator i, Destroyer destroyer) - { return this->erase_after_and_destroy(this->previous(i), destroyer); } + template + iterator erase_and_dispose(iterator i, Disposer disposer) + { return this->erase_after_and_dispose(this->previous(i), disposer); } //! Requires: first and last must be valid iterator to elements in *this. - //! Destroyer::operator()(pointer) shouldn't throw. + //! Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the range pointed by b and e. //! No destructors are called. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: the first element remaining beyond the removed elements, //! or end() if no such element exists. @@ -776,9 +774,9 @@ class slist //! //! Note: Invalidates the iterators (but not the references) to the //! erased elements. - template - iterator erase_and_destroy(iterator first, iterator last, Destroyer destroyer) - { return erase_after_and_destroy(this->previous(first), last, destroyer); } + template + iterator erase_and_dispose(iterator first, iterator last, Disposer disposer) + { return erase_after_and_dispose(this->previous(first), last, disposer); } //! Requires: Dereferencing iterator must yield //! an lvalue of type value_type. @@ -802,14 +800,14 @@ class slist this->insert_after(before_begin(), b, e); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Requires: Dereferencing iterator must yield //! an lvalue of type value_type. //! //! Effects: Clears the list and inserts the range pointed by b and e. //! No destructors or copy constructors are called. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Throws: Nothing. //! @@ -818,11 +816,11 @@ class slist //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. - template - void destroy_and_assign(Destroyer destroyer, Iterator b, Iterator e) + template + void dispose_and_assign(Disposer disposer, Iterator b, Iterator e) { - this->clear_and_destroy(destroyer); - this->insert_after_and_destroy(before_begin(), b, e, destroyer); + this->clear_and_dispose(disposer); + this->insert_after_and_dispose(before_begin(), b, e, disposer); } //! Requires: prev is an iterator to an element or x.end()/x.before_begin() in x. @@ -932,7 +930,7 @@ class slist { if(n){ if(ConstantTimeSize){ - BOOST_ASSERT(std::distance(before_first, before_last) == n); + BOOST_INTRUSIVE_INVARIANT_ASSERT(std::distance(before_first, before_last) == n); node_algorithms::transfer_after (prev_pos.pointed_node(), before_first.pointed_node(), before_last.pointed_node()); size_traits::set_size(size_traits::get_size() + n); @@ -1042,7 +1040,7 @@ class slist while(i < fill && !counter[i].empty()) { last_inserted = carry.merge(counter[i++], p); } - BOOST_ASSERT(counter[i].empty()); + BOOST_INTRUSIVE_INVARIANT_ASSERT(counter[i].empty()); iterator last_element(previous_node(last_inserted, carry.end())); if(ConstantTimeSize){ @@ -1063,7 +1061,7 @@ class slist for (int i = 1; i < fill; ++i) last_inserted = counter[i].merge(counter[i-1], p); //this->swap(counter[fill-1]); - BOOST_ASSERT(this->empty()); + BOOST_INTRUSIVE_INVARIANT_ASSERT(this->empty()); iterator last_element(previous_node(last_inserted, counter[--fill].end())); if(ConstantTimeSize){ @@ -1174,10 +1172,10 @@ class slist void remove(const_reference value) { remove_if(detail::equal_to_value(value)); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Removes all the elements that compare equal to value. - //! Destroyer::operator()(pointer) is called for every removed element. + //! Disposer::operator()(pointer) is called for every removed element. //! //! Throws: If std::equal_to throws. Basic guarantee. //! @@ -1185,9 +1183,9 @@ class slist //! //! Note: The relative order of elements that are not removed is unchanged, //! and iterators to elements that are not removed remain valid. - template - void remove_and_destroy(const_reference value, Destroyer destroyer) - { remove_and_destroy_if(detail::equal_to_value(value), destroyer); } + template + void remove_and_dispose(const_reference value, Disposer disposer) + { remove_and_dispose_if(detail::equal_to_value(value), disposer); } //! Effects: Removes all the elements for which a specified //! predicate is satisfied. No destructors are called. @@ -1200,13 +1198,13 @@ class slist //! and iterators to elements that are not removed remain valid. template void remove_if(Pred pred) - { remove_and_destroy_if(pred, detail::null_destroyer()); } + { remove_and_dispose_if(pred, detail::null_disposer()); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Removes all the elements for which a specified //! predicate is satisfied. - //! Destroyer::operator()(pointer) is called for every removed element. + //! Disposer::operator()(pointer) is called for every removed element. //! //! Throws: If pred throws. Basic guarantee. //! @@ -1214,8 +1212,8 @@ class slist //! //! Note: The relative order of elements that are not removed is unchanged, //! and iterators to elements that are not removed remain valid. - template - void remove_and_destroy_if(Pred pred, Destroyer destroyer) + template + void remove_and_dispose_if(Pred pred, Disposer disposer) { iterator bcur(this->before_begin()), cur, e(this->end()); @@ -1223,7 +1221,7 @@ class slist if (pred(*cur)){ pointer p = cur.operator->(); this->erase_after(bcur); - destroyer(p); + disposer(p); } else{ ++bcur; @@ -1241,7 +1239,7 @@ class slist //! Note: The relative order of elements that are not removed is unchanged, //! and iterators to elements that are not removed remain valid. void unique() - { unique_and_destroy(std::equal_to(), detail::null_destroyer()); } + { unique_and_dispose(std::equal_to(), detail::null_disposer()); } //! Effects: Removes adjacent duplicate elements or adjacent //! elements that satisfy some binary predicate from the list. @@ -1255,13 +1253,13 @@ class slist //! and iterators to elements that are not removed remain valid. template void unique(BinaryPredicate pred) - { unique_and_destroy(pred, detail::null_destroyer()); } + { unique_and_dispose(pred, detail::null_disposer()); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Removes adjacent duplicate elements or adjacent //! elements that satisfy some binary predicate from the list. - //! Destroyer::operator()(pointer) is called for every removed element. + //! Disposer::operator()(pointer) is called for every removed element. //! //! Throws: If std::equal_to throws. Basic guarantee. //! @@ -1269,15 +1267,15 @@ class slist //! //! Note: The relative order of elements that are not removed is unchanged, //! and iterators to elements that are not removed remain valid. - template - void unique_and_destroy(Destroyer destroyer) - { unique(std::equal_to(), destroyer); } + template + void unique_and_dispose(Disposer disposer) + { unique(std::equal_to(), disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Removes adjacent duplicate elements or adjacent //! elements that satisfy some binary predicate from the list. - //! Destroyer::operator()(pointer) is called for every removed element. + //! Disposer::operator()(pointer) is called for every removed element. //! //! Throws: If the predicate throws. Basic guarantee. //! @@ -1285,8 +1283,8 @@ class slist //! //! Note: The relative order of elements that are not removed is unchanged, //! and iterators to elements that are not removed remain valid. - template - void unique_and_destroy(BinaryPredicate pred, Destroyer destroyer) + template + void unique_and_dispose(BinaryPredicate pred, Disposer disposer) { iterator end_n(end()); iterator cur(begin()); @@ -1297,7 +1295,7 @@ class slist if (pred(*cur, *cur_next)){ pointer p = cur_next.operator->(); this->erase_after(cur); - destroyer(p); + disposer(p); } else{ ++cur; @@ -1317,7 +1315,7 @@ class slist //! Note: Iterators and references are not invalidated. static iterator iterator_to(reference value) { - BOOST_ASSERT (!node_algorithms::unique(ValueTraits::to_node_ptr(value))); + BOOST_INTRUSIVE_INVARIANT_ASSERT (!node_algorithms::unique(ValueTraits::to_node_ptr(value))); return iterator (ValueTraits::to_node_ptr(value)); } @@ -1332,7 +1330,7 @@ class slist //! Note: Iterators and references are not invalidated. static const_iterator iterator_to(const_reference value) { - BOOST_ASSERT (!node_algorithms::unique(ValueTraits::to_node_ptr(const_cast (value)))); + BOOST_INTRUSIVE_INVARIANT_ASSERT (!node_algorithms::unique(ValueTraits::to_node_ptr(const_cast (value)))); return const_iterator (ValueTraits::to_node_ptr(const_cast (value))); } diff --git a/include/boost/intrusive/slist_hook.hpp b/include/boost/intrusive/slist_hook.hpp index 6a54e9f..ccc7bb2 100644 --- a/include/boost/intrusive/slist_hook.hpp +++ b/include/boost/intrusive/slist_hook.hpp @@ -23,7 +23,6 @@ #include #include #include -#include namespace boost { namespace intrusive { diff --git a/include/boost/intrusive/unordered_set.hpp b/include/boost/intrusive/unordered_set.hpp index 841f78e..b5f5305 100644 --- a/include/boost/intrusive/unordered_set.hpp +++ b/include/boost/intrusive/unordered_set.hpp @@ -121,8 +121,8 @@ class unordered_set //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! or the copy constructor or invocation of Hash or Equal throws. //! - //! Notes: buckets array must be destroyed only after - //! *this is destroyed. + //! Notes: buckets array must be disposed only after + //! *this is disposed. unordered_set( bucket_ptr buckets , size_type buckets_len , const Hash & hasher = Hash() @@ -143,8 +143,8 @@ class unordered_set //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! or the copy constructor or invocation of Hash or Equal throws. //! - //! Notes: buckets array must be destroyed only after - //! *this is destroyed. + //! Notes: buckets array must be disposed only after + //! *this is disposed. template unordered_set( bucket_ptr buckets , size_type buckets_len @@ -266,22 +266,22 @@ class unordered_set void swap(unordered_set& other) { table_.swap(other.table_); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements from *this - //! calling Destroyer::operator()(pointer), clones all the + //! calling Disposer::operator()(pointer), clones all the //! elements from src calling Cloner::operator()(const_reference ) //! and inserts them on *this. //! - //! If cloner throws, all cloned elements are unlinked and destroyed - //! calling Destroyer::operator()(pointer). + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). //! //! Complexity: Linear to erased plus inserted elements. //! //! Throws: If cloner throws. Basic guarantee. - template - void clone_from(const unordered_set &src, Cloner cloner, Destroyer destroyer) - { table_.clone_from(src.table_, cloner, destroyer); } + template + void clone_from(const unordered_set &src, Cloner cloner, Disposer disposer) + { table_.clone_from(src.table_, cloner, disposer); } //! Requires: value must be an lvalue //! @@ -441,10 +441,10 @@ class unordered_set size_type erase(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) { return table_.erase(key, hasher, equal); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the element pointed to by i. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Complexity: Average case O(1), worst case O(this->size()). //! @@ -452,14 +452,14 @@ class unordered_set //! //! Note: Invalidates the iterators //! to the erased elements. - template - iterator erase_and_destroy(const_iterator i, Destroyer destroyer) - { return table_.erase_and_destroy(i, destroyer); } + template + iterator erase_and_dispose(const_iterator i, Disposer disposer) + { return table_.erase_and_dispose(i, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the range pointed to by b end e. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Complexity: Average case O(std::distance(b, e)), //! worst case O(this->size()). @@ -468,14 +468,14 @@ class unordered_set //! //! Note: Invalidates the iterators //! to the erased elements. - template - iterator erase_and_destroy(const_iterator b, const_iterator e, Destroyer destroyer) - { return table_.erase_and_destroy(b, e, destroyer); } + template + iterator erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { return table_.erase_and_dispose(b, e, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given value. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: The number of erased elements. //! @@ -486,15 +486,15 @@ class unordered_set //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. No destructors are called. - template - size_type erase_and_destroy(const_reference value, Destroyer destroyer) - { return table_.erase_and_destroy(value, destroyer); } + template + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return table_.erase_and_dispose(value, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given key. //! according to the comparison functor "equal". - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: The number of erased elements. //! @@ -505,9 +505,9 @@ class unordered_set //! //! Note: Invalidates the iterators //! to the erased elements. - template - size_type erase_and_destroy(const KeyType& key, KeyHasher hasher, KeyValueEqual equal, Destroyer destroyer) - { return table_.erase_and_destroy(key, hasher, equal, destroyer); } + template + size_type erase_and_dispose(const KeyType& key, KeyHasher hasher, KeyValueEqual equal, Disposer disposer) + { return table_.erase_and_dispose(key, hasher, equal, disposer); } //! Effects: Erases all of the elements. //! @@ -521,20 +521,20 @@ class unordered_set void clear() { return table_.clear(); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all of the elements. //! //! Complexity: Linear to the number of elements on the container. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Throws: Nothing. //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. No destructors are called. - template - void clear_and_destroy(Destroyer destroyer) - { return table_.clear_and_destroy(destroyer); } + template + void clear_and_dispose(Disposer disposer) + { return table_.clear_and_dispose(disposer); } //! Effects: Returns the number of contained elements with the given value //! @@ -557,7 +557,7 @@ class unordered_set //! Complexity: Average case O(1), worst case O(this->size()). //! //! Throws: If hasher or equal throw. - template + template size_type count(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) const { return table_.find(key, hasher, equal) != end(); } @@ -1019,8 +1019,8 @@ class unordered_multiset //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! or the copy constructor or invocation of Hash or Equal throws. //! - //! Notes: buckets array must be destroyed only after - //! *this is destroyed. + //! Notes: buckets array must be disposed only after + //! *this is disposed. unordered_multiset ( bucket_ptr buckets , size_type buckets_len , const Hash & hasher = Hash() @@ -1041,8 +1041,8 @@ class unordered_multiset //! constructor throws (this does not happen with predefined Boost.Intrusive hooks) //! or the copy constructor or invocation of Hash or Equal throws. //! - //! Notes: buckets array must be destroyed only after - //! *this is destroyed. + //! Notes: buckets array must be disposed only after + //! *this is disposed. template unordered_multiset ( bucket_ptr buckets , size_type buckets_len @@ -1165,22 +1165,22 @@ class unordered_multiset void swap(unordered_multiset& other) { table_.swap(other.table_); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements from *this - //! calling Destroyer::operator()(pointer), clones all the + //! calling Disposer::operator()(pointer), clones all the //! elements from src calling Cloner::operator()(const_reference ) //! and inserts them on *this. //! - //! If cloner throws, all cloned elements are unlinked and destroyed - //! calling Destroyer::operator()(pointer). + //! If cloner throws, all cloned elements are unlinked and disposed + //! calling Disposer::operator()(pointer). //! //! Complexity: Linear to erased plus inserted elements. //! //! Throws: If cloner throws. - template - void clone_from(const unordered_multiset &src, Cloner cloner, Destroyer destroyer) - { table_.clone_from(src.table_, cloner, destroyer); } + template + void clone_from(const unordered_multiset &src, Cloner cloner, Disposer disposer) + { table_.clone_from(src.table_, cloner, disposer); } //! Requires: value must be an lvalue //! @@ -1275,10 +1275,10 @@ class unordered_multiset size_type erase(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) { return table_.erase(key, hasher, equal); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the element pointed to by i. - //! Destroyer::operator()(pointer) is called for the removed element. + //! Disposer::operator()(pointer) is called for the removed element. //! //! Complexity: Average case O(1), worst case O(this->size()). //! @@ -1286,14 +1286,14 @@ class unordered_multiset //! //! Note: Invalidates the iterators //! to the erased elements. - template - void erase_and_destroy(const_iterator i, Destroyer destroyer) - { table_.erase_and_destroy(i, destroyer); } + template + void erase_and_dispose(const_iterator i, Disposer disposer) + { table_.erase_and_dispose(i, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases the range pointed to by b end e. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Complexity: Average case O(std::distance(b, e)), //! worst case O(this->size()). @@ -1302,14 +1302,14 @@ class unordered_multiset //! //! Note: Invalidates the iterators //! to the erased elements. - template - void erase_and_destroy(const_iterator b, const_iterator e, Destroyer destroyer) - { table_.erase_and_destroy(b, e, destroyer); } + template + void erase_and_dispose(const_iterator b, const_iterator e, Disposer disposer) + { table_.erase_and_dispose(b, e, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given value. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: The number of erased elements. //! @@ -1320,15 +1320,15 @@ class unordered_multiset //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. No destructors are called. - template - size_type erase_and_destroy(const_reference value, Destroyer destroyer) - { return table_.erase_and_destroy(value, destroyer); } + template + size_type erase_and_dispose(const_reference value, Disposer disposer) + { return table_.erase_and_dispose(value, disposer); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements with the given key. //! according to the comparison functor "equal". - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Returns: The number of erased elements. //! @@ -1339,9 +1339,9 @@ class unordered_multiset //! //! Note: Invalidates the iterators //! to the erased elements. - template - size_type erase_and_destroy(const KeyType& key, KeyHasher hasher, KeyValueEqual equal, Destroyer destroyer) - { return table_.erase_and_destroy(key, hasher, equal, destroyer); } + template + size_type erase_and_dispose(const KeyType& key, KeyHasher hasher, KeyValueEqual equal, Disposer disposer) + { return table_.erase_and_dispose(key, hasher, equal, disposer); } //! Effects: Erases all the elements of the container. //! @@ -1355,20 +1355,20 @@ class unordered_multiset void clear() { return table_.clear(); } - //! Requires: Destroyer::operator()(pointer) shouldn't throw. + //! Requires: Disposer::operator()(pointer) shouldn't throw. //! //! Effects: Erases all the elements of the container. //! //! Complexity: Linear to the number of elements on the container. - //! Destroyer::operator()(pointer) is called for the removed elements. + //! Disposer::operator()(pointer) is called for the removed elements. //! //! Throws: Nothing. //! //! Note: Invalidates the iterators (but not the references) //! to the erased elements. No destructors are called. - template - void clear_and_destroy(Destroyer destroyer) - { return table_.clear_and_destroy(destroyer); } + template + void clear_and_dispose(Disposer disposer) + { return table_.clear_and_dispose(disposer); } //! Effects: Returns the number of contained elements with the given key //! @@ -1391,7 +1391,7 @@ class unordered_multiset //! Complexity: Average case O(1), worst case O(this->size()). //! //! Throws: If the internal hasher or the equality functor throws. - template + template size_type count(const KeyType& key, KeyHasher hasher, KeyValueEqual equal) const { return table_.count(key, hasher, equal); } diff --git a/include/boost/intrusive/unordered_set_hook.hpp b/include/boost/intrusive/unordered_set_hook.hpp index a0d3c3d..767b8a5 100644 --- a/include/boost/intrusive/unordered_set_hook.hpp +++ b/include/boost/intrusive/unordered_set_hook.hpp @@ -20,7 +20,6 @@ #include #include #include -#include namespace boost { namespace intrusive {