diff --git a/include/boost/intrusive/detail/generic_hook.hpp b/include/boost/intrusive/detail/generic_hook.hpp index c85b389..13421b8 100644 --- a/include/boost/intrusive/detail/generic_hook.hpp +++ b/include/boost/intrusive/detail/generic_hook.hpp @@ -146,7 +146,7 @@ class generic_hook //value_traits for this hook. , public hook_tags_definer < generic_hook - , detail::is_same::value*BaseHookType> + , detail::is_same::value ? BaseHookType : NoBaseHookId> /// @endcond { /// @cond diff --git a/include/boost/intrusive/sgtree.hpp b/include/boost/intrusive/sgtree.hpp index c82551f..ce4c039 100644 --- a/include/boost/intrusive/sgtree.hpp +++ b/include/boost/intrusive/sgtree.hpp @@ -156,6 +156,9 @@ struct alpha_holder multiply_by_alpha_t get_multiply_by_alpha_t() const { return multiply_by_alpha_t(alpha_); } + SizeType &get_max_tree_size() + { return max_tree_size_; } + protected: float alpha_; float inv_minus_logalpha_; @@ -189,6 +192,10 @@ struct alpha_holder multiply_by_alpha_t get_multiply_by_alpha_t() const { return multiply_by_alpha_t(); } + SizeType &get_max_tree_size() + { return max_tree_size_; } + + protected: SizeType max_tree_size_; }; @@ -714,14 +721,14 @@ class sgtree_impl it = node_algorithms::next_node(it); std::size_t max_tree1_size = this->max_tree_size_; - std::size_t max_tree2_size = source.max_tree_size_; + std::size_t max_tree2_size = source.get_max_tree_size(); if( node_algorithms::transfer_unique ( this->header_ptr(), this->key_node_comp(this->key_comp()), this->size(), max_tree1_size , source.header_ptr(), p, source.size(), max_tree2_size , this->get_h_alpha_func(), this->get_alpha_by_max_size_func()) ){ this->max_tree_size_ = (size_type)max_tree1_size; this->sz_traits().increment(); - source.max_tree_size_ = (size_type)max_tree2_size; + source.get_max_tree_size() = (size_type)max_tree2_size; source.sz_traits().decrement(); } } @@ -744,14 +751,14 @@ class sgtree_impl BOOST_INTRUSIVE_SAFE_HOOK_DEFAULT_ASSERT(!safemode_or_autounlink || !node_algorithms::unique(p)); it = node_algorithms::next_node(it); std::size_t max_tree1_size = this->max_tree_size_; - std::size_t max_tree2_size = source.max_tree_size_; + std::size_t max_tree2_size = source.get_max_tree_size(); node_algorithms::transfer_equal ( this->header_ptr(), this->key_node_comp(this->key_comp()), this->size(), max_tree1_size , source.header_ptr(), p, source.size(), max_tree2_size , this->get_h_alpha_func(), this->get_alpha_by_max_size_func()); this->max_tree_size_ = (size_type)max_tree1_size; this->sz_traits().increment(); - source.max_tree_size_ = (size_type)max_tree2_size; + source.get_max_tree_size() = (size_type)max_tree2_size; source.sz_traits().decrement(); } } diff --git a/test/bptr_value.hpp b/test/bptr_value.hpp index 56c0c60..a2995d3 100644 --- a/test/bptr_value.hpp +++ b/test/bptr_value.hpp @@ -85,6 +85,15 @@ struct BPtr_Value friend bool operator< (const BPtr_Value &other1, int other2) { return other1.value_ < other2; } + friend bool operator> (const BPtr_Value &other1, const BPtr_Value &other2) + { return other1.value_ > other2.value_; } + + friend bool operator> (int other1, const BPtr_Value &other2) + { return other1 > other2.value_; } + + friend bool operator> (const BPtr_Value &other1, int other2) + { return other1.value_ > other2; } + friend bool operator== (const BPtr_Value &other1, const BPtr_Value &other2) { return other1.value_ == other2.value_; } diff --git a/test/generic_multiset_test.hpp b/test/generic_multiset_test.hpp index ba86bfc..6caeca2 100644 --- a/test/generic_multiset_test.hpp +++ b/test/generic_multiset_test.hpp @@ -181,11 +181,16 @@ void test_generic_multiset::test_merge(value_cont_type& values typedef typename ContainerDefiner::template container <>::type multiset_type; typedef typename multiset_type::key_of_value key_of_value; + typedef typename multiset_type::key_type key_type; + + typedef typename ContainerDefiner::template container + < compare< std::greater > >::type multiset_greater_type; + //original vector: 3, 2, 4, 1, 5, 2 //2,3 multiset_type testset1 (values.begin(), values.begin() + 2); - //1, 2, 4, 5 - multiset_type testset2; + //5, 4, 2, 1 + multiset_greater_type testset2; testset2.insert (values.begin() + 2, values.begin() + 6); testset2.merge(testset1); @@ -194,7 +199,7 @@ void test_generic_multiset::test_merge(value_cont_type& values BOOST_TEST (testset1.empty()); BOOST_TEST (testset2.size() == 6); - { int init_values [] = { 1, 2, 2, 3, 4, 5 }; + { int init_values [] = { 5, 4, 3, 2, 2, 1 }; TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); } value_cont_type cmp_val_cont(1); diff --git a/test/generic_set_test.hpp b/test/generic_set_test.hpp index 58f46b8..e3425d1 100644 --- a/test/generic_set_test.hpp +++ b/test/generic_set_test.hpp @@ -263,10 +263,15 @@ void test_generic_set::test_merge(value_cont_type& values) { typedef typename ContainerDefiner::template container <>::type set_type; + typedef typename set_type::key_type key_type; + + typedef typename ContainerDefiner::template container + < compare< std::greater > >::type set_greater_type; + //2,3 set_type testset1 (values.begin(), values.begin() + 2); - //1, 2, 4, 5 - set_type testset2; + //5, 4, 2, 1 + set_greater_type testset2; testset2.insert (values.begin() + 2, values.begin() + 6); testset2.merge(testset1); @@ -279,7 +284,7 @@ void test_generic_set::test_merge(value_cont_type& values) BOOST_TEST (&*testset1.begin() == &values[1]); BOOST_TEST (testset2.size() == 5); - { int init_values [] = { 1, 2, 3, 4, 5 }; + { int init_values [] = { 5, 4, 3, 2, 1 }; TEST_INTRUSIVE_SEQUENCE( init_values, testset2.begin() ); } testset1.merge(testset2); diff --git a/test/itestvalue.hpp b/test/itestvalue.hpp index 5344532..0f24bbf 100644 --- a/test/itestvalue.hpp +++ b/test/itestvalue.hpp @@ -96,6 +96,9 @@ struct testvalue bool operator< (const testvalue &other) const { return value_ < other.value_; } + bool operator> (const testvalue &other) const + { return value_ > other.value_; } + bool operator==(const testvalue &other) const { return value_ == other.value_; } @@ -105,9 +108,15 @@ struct testvalue friend bool operator< (int other1, const testvalue &other2) { return other1 < other2.value_.int_; } + friend bool operator> (int other1, const testvalue &other2) + { return other1 > other2.value_.int_; } + friend bool operator< (const testvalue &other1, int other2) { return other1.value_.int_ < other2; } + friend bool operator> (const testvalue &other1, int other2) + { return other1.value_.int_ > other2; } + friend bool operator== (int other1, const testvalue &other2) { return other1 == other2.value_.int_; }