From 85ba9b5ae91af679c4442f3b425da04ed3e6cc9d Mon Sep 17 00:00:00 2001 From: khizmax Date: Thu, 24 Dec 2015 17:59:39 +0300 Subject: [PATCH] Fixed compatibility with boost 1.59 for striped intrusive sets --- cds/intrusive/striped_set/adapter.h | 2 +- ...hdr_intrusive_refinable_hashset_avlset.cpp | 35 ++++++++++- .../hdr_intrusive_refinable_hashset_set.cpp | 39 ++++++++++-- .../hdr_intrusive_refinable_hashset_sgset.cpp | 35 ++++++++++- ...r_intrusive_refinable_hashset_splayset.cpp | 35 ++++++++++- ...r_intrusive_refinable_hashset_treapset.cpp | 38 +++++++++++- .../hdr_intrusive_striped_hashset_avlset.cpp | 35 ++++++++++- .../set/hdr_intrusive_striped_hashset_set.cpp | 36 ++++++++++- .../hdr_intrusive_striped_hashset_sgset.cpp | 36 ++++++++++- ...hdr_intrusive_striped_hashset_splayset.cpp | 40 ++++++++++-- ...hdr_intrusive_striped_hashset_treapset.cpp | 38 +++++++++++- .../test-hdr/set/hdr_intrusive_striped_set.h | 61 ++++++++++++++++--- 12 files changed, 385 insertions(+), 45 deletions(-) diff --git a/cds/intrusive/striped_set/adapter.h b/cds/intrusive/striped_set/adapter.h index 67be8d43..042e968f 100644 --- a/cds/intrusive/striped_set/adapter.h +++ b/cds/intrusive/striped_set/adapter.h @@ -237,7 +237,7 @@ namespace cds { namespace intrusive { bool unlink( value_type& val ) { - iterator it = m_Set.find( value_type(val) ); + iterator it = m_Set.find( value_type(val)); if ( it == m_Set.end() || &(*it) != &val ) return false; m_Set.erase( it ); diff --git a/tests/test-hdr/set/hdr_intrusive_refinable_hashset_avlset.cpp b/tests/test-hdr/set/hdr_intrusive_refinable_hashset_avlset.cpp index b754e763..7343d7c9 100644 --- a/tests/test-hdr/set/hdr_intrusive_refinable_hashset_avlset.cpp +++ b/tests/test-hdr/set/hdr_intrusive_refinable_hashset_avlset.cpp @@ -10,12 +10,32 @@ namespace set { namespace { typedef IntrusiveStripedSetHdrTest::base_item< bi::avl_set_base_hook<> > base_item_type; typedef IntrusiveStripedSetHdrTest::member_item< bi::avl_set_member_hook<> > member_item_type; + + template + struct get_key + { + typedef T type; + + type const& operator()( Node const& v ) const + { + return v.nKey; + } + }; } +#if BOOST_VERSION >= 105900 +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>> +#else +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) +#endif + void IntrusiveStripedSetHdrTest::Refinable_avl_set_basehook() { typedef ci::StripedSet< - bi::avl_set > > + bi::avl_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::back_off< cds::backoff::empty > @@ -27,7 +47,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Refinable_avl_set_basehook_bucket_threshold() { typedef ci::StripedSet< - bi::avl_set > > + bi::avl_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> > ,co::mutex_policy< ci::striped_set::refinable<> > @@ -39,7 +62,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Refinable_avl_set_basehook_bucket_threshold_rt() { typedef ci::StripedSet< - bi::avl_set > > + bi::avl_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > ,co::mutex_policy< ci::striped_set::refinable<> > @@ -56,6 +82,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > @@ -71,6 +98,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > @@ -87,6 +115,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::mutex_policy< ci::striped_set::refinable<> > diff --git a/tests/test-hdr/set/hdr_intrusive_refinable_hashset_set.cpp b/tests/test-hdr/set/hdr_intrusive_refinable_hashset_set.cpp index 0c65ea6e..ba05b916 100644 --- a/tests/test-hdr/set/hdr_intrusive_refinable_hashset_set.cpp +++ b/tests/test-hdr/set/hdr_intrusive_refinable_hashset_set.cpp @@ -10,12 +10,32 @@ namespace set { namespace { typedef IntrusiveStripedSetHdrTest::base_item< bi::set_base_hook<> > base_item_type; typedef IntrusiveStripedSetHdrTest::member_item< bi::set_member_hook<> > member_item_type; + + template + struct get_key + { + typedef T type; + + type const& operator()( Node const& v ) const + { + return v.nKey; + } + }; } +#if BOOST_VERSION >= 105900 +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>> +#else +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) +#endif + void IntrusiveStripedSetHdrTest::Refinable_set_basehook() { typedef ci::StripedSet< - bi::set > > + bi::set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::mutex_policy< ci::striped_set::refinable<> > > set_type; @@ -26,7 +46,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Refinable_set_basehook_bucket_threshold() { typedef ci::StripedSet< - bi::set > > + bi::set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> > ,co::mutex_policy< ci::striped_set::refinable<> > @@ -38,7 +61,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Refinable_set_basehook_bucket_threshold_rt() { typedef ci::StripedSet< - bi::set > > + bi::set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > ,co::mutex_policy< ci::striped_set::refinable<> > @@ -55,6 +81,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::mutex_policy< ci::striped_set::refinable<> > @@ -69,7 +96,8 @@ namespace set { bi::set< member_item_type , bi::member_hook< member_item_type, bi::set_member_hook<>, &member_item_type::hMember> - , bi::compare > + , bi::compare> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > @@ -85,7 +113,8 @@ namespace set { bi::set< member_item_type , bi::member_hook< member_item_type, bi::set_member_hook<>, &member_item_type::hMember> - , bi::compare > + , bi::compare> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > diff --git a/tests/test-hdr/set/hdr_intrusive_refinable_hashset_sgset.cpp b/tests/test-hdr/set/hdr_intrusive_refinable_hashset_sgset.cpp index 0ce2ee6b..d9b0eccc 100644 --- a/tests/test-hdr/set/hdr_intrusive_refinable_hashset_sgset.cpp +++ b/tests/test-hdr/set/hdr_intrusive_refinable_hashset_sgset.cpp @@ -10,12 +10,32 @@ namespace set { namespace { typedef IntrusiveStripedSetHdrTest::base_item< bi::bs_set_base_hook<> > base_item_type; typedef IntrusiveStripedSetHdrTest::member_item< bi::bs_set_member_hook<> > member_item_type; + + template + struct get_key + { + typedef T type; + + type const& operator()( Node const& v ) const + { + return v.nKey; + } + }; } +#if BOOST_VERSION >= 105900 +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>> +#else +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) +#endif + void IntrusiveStripedSetHdrTest::Refinable_sg_set_basehook() { typedef ci::StripedSet< - bi::sg_set > > + bi::sg_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::mutex_policy< ci::striped_set::refinable<> > > set_type; @@ -26,7 +46,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Refinable_sg_set_basehook_bucket_threshold() { typedef ci::StripedSet< - bi::sg_set > > + bi::sg_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> > ,co::mutex_policy< ci::striped_set::refinable<> > @@ -38,7 +61,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Refinable_sg_set_basehook_bucket_threshold_rt() { typedef ci::StripedSet< - bi::sg_set > > + bi::sg_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > ,co::mutex_policy< ci::striped_set::refinable<> > @@ -55,6 +81,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > @@ -70,6 +97,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > @@ -86,6 +114,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > diff --git a/tests/test-hdr/set/hdr_intrusive_refinable_hashset_splayset.cpp b/tests/test-hdr/set/hdr_intrusive_refinable_hashset_splayset.cpp index 41304efc..5fbbb853 100644 --- a/tests/test-hdr/set/hdr_intrusive_refinable_hashset_splayset.cpp +++ b/tests/test-hdr/set/hdr_intrusive_refinable_hashset_splayset.cpp @@ -18,12 +18,32 @@ namespace set { #endif typedef IntrusiveStripedSetHdrTest::base_item< splay_set_base_hook > base_item_type; typedef IntrusiveStripedSetHdrTest::member_item< splay_set_member_hook > member_item_type; + + template + struct get_key + { + typedef T type; + + type const& operator()( Node const& v ) const + { + return v.nKey; + } + }; } +#if BOOST_VERSION >= 105900 +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>> +#else +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) +#endif + void IntrusiveStripedSetHdrTest::Refinable_splay_set_basehook() { typedef ci::StripedSet< - bi::splay_set > > + bi::splay_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::back_off< cds::backoff::empty > @@ -35,7 +55,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Refinable_splay_set_basehook_bucket_threshold() { typedef ci::StripedSet< - bi::splay_set > > + bi::splay_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> > @@ -47,7 +70,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Refinable_splay_set_basehook_bucket_threshold_rt() { typedef ci::StripedSet< - bi::splay_set > > + bi::splay_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > @@ -64,6 +90,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > @@ -79,6 +106,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > @@ -95,6 +123,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > diff --git a/tests/test-hdr/set/hdr_intrusive_refinable_hashset_treapset.cpp b/tests/test-hdr/set/hdr_intrusive_refinable_hashset_treapset.cpp index a8276918..84bf5ec7 100644 --- a/tests/test-hdr/set/hdr_intrusive_refinable_hashset_treapset.cpp +++ b/tests/test-hdr/set/hdr_intrusive_refinable_hashset_treapset.cpp @@ -22,12 +22,33 @@ namespace set { return base_class::operator()( b, a ); } }; + + template + struct get_key + { + typedef T type; + + type const& operator()( Node const& v ) const + { + return v.nKey; + } + }; } +#if BOOST_VERSION >= 105900 +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>> +#else +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) +#endif + void IntrusiveStripedSetHdrTest::Refinable_treap_set_basehook() { typedef ci::StripedSet< - bi::treap_set >, bi::priority > > + bi::treap_set> + , bi::priority> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > > set_type; @@ -38,7 +59,11 @@ namespace set { void IntrusiveStripedSetHdrTest::Refinable_treap_set_basehook_bucket_threshold() { typedef ci::StripedSet< - bi::treap_set >, bi::priority > > + bi::treap_set > + , bi::priority> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> > @@ -50,7 +75,11 @@ namespace set { void IntrusiveStripedSetHdrTest::Refinable_treap_set_basehook_bucket_threshold_rt() { typedef ci::StripedSet< - bi::treap_set >, bi::priority > > + bi::treap_set> + , bi::priority> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > @@ -68,6 +97,7 @@ namespace set { , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > , bi::priority > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > @@ -84,6 +114,7 @@ namespace set { , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > , bi::priority > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::mutex_policy< ci::striped_set::refinable<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > @@ -101,6 +132,7 @@ namespace set { , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > , bi::priority > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > diff --git a/tests/test-hdr/set/hdr_intrusive_striped_hashset_avlset.cpp b/tests/test-hdr/set/hdr_intrusive_striped_hashset_avlset.cpp index ee40897f..e2882564 100644 --- a/tests/test-hdr/set/hdr_intrusive_striped_hashset_avlset.cpp +++ b/tests/test-hdr/set/hdr_intrusive_striped_hashset_avlset.cpp @@ -10,12 +10,32 @@ namespace set { namespace { typedef IntrusiveStripedSetHdrTest::base_item< bi::avl_set_base_hook<> > base_item_type; typedef IntrusiveStripedSetHdrTest::member_item< bi::avl_set_member_hook<> > member_item_type; + + template + struct get_key + { + typedef T type; + + type const& operator()( Node const& v ) const + { + return v.nKey; + } + }; } +#if BOOST_VERSION >= 105900 +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>> +#else +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) +#endif + void IntrusiveStripedSetHdrTest::Striped_avl_set_basehook() { typedef ci::StripedSet< - bi::avl_set > > + bi::avl_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::mutex_policy< ci::striped_set::striping<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > > set_type; @@ -26,7 +46,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Striped_avl_set_basehook_bucket_threshold() { typedef ci::StripedSet< - bi::avl_set > > + bi::avl_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> > > set_type; @@ -37,7 +60,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Striped_avl_set_basehook_bucket_threshold_rt() { typedef ci::StripedSet< - bi::avl_set > > + bi::avl_set > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > > set_type; @@ -53,6 +79,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > > set_type; @@ -67,6 +94,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > @@ -82,6 +110,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > diff --git a/tests/test-hdr/set/hdr_intrusive_striped_hashset_set.cpp b/tests/test-hdr/set/hdr_intrusive_striped_hashset_set.cpp index c97a89ca..ac29ba1c 100644 --- a/tests/test-hdr/set/hdr_intrusive_striped_hashset_set.cpp +++ b/tests/test-hdr/set/hdr_intrusive_striped_hashset_set.cpp @@ -10,12 +10,33 @@ namespace set { namespace { typedef IntrusiveStripedSetHdrTest::base_item< bi::set_base_hook<> > base_item_type; typedef IntrusiveStripedSetHdrTest::member_item< bi::set_member_hook<> > member_item_type; + + template + struct get_key + { + typedef T type; + + type const& operator()( Node const& v ) const + { + return v.nKey; + } + }; } +#if BOOST_VERSION >= 105900 +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>> +#else +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) +#endif + + void IntrusiveStripedSetHdrTest::Striped_set_basehook() { typedef ci::StripedSet< - bi::set > > + bi::set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::mutex_policy< ci::striped_set::striping<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > > set_type; @@ -26,7 +47,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Striped_set_basehook_bucket_threshold() { typedef ci::StripedSet< - bi::set > > + bi::set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> > > set_type; @@ -37,7 +61,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Striped_set_basehook_bucket_threshold_rt() { typedef ci::StripedSet< - bi::set > > + bi::set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > > set_type; @@ -53,6 +80,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > > set_type; @@ -67,6 +95,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > @@ -82,6 +111,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > diff --git a/tests/test-hdr/set/hdr_intrusive_striped_hashset_sgset.cpp b/tests/test-hdr/set/hdr_intrusive_striped_hashset_sgset.cpp index dddd88a8..e03735af 100644 --- a/tests/test-hdr/set/hdr_intrusive_striped_hashset_sgset.cpp +++ b/tests/test-hdr/set/hdr_intrusive_striped_hashset_sgset.cpp @@ -10,12 +10,33 @@ namespace set { namespace { typedef IntrusiveStripedSetHdrTest::base_item< bi::bs_set_base_hook<> > base_item_type; typedef IntrusiveStripedSetHdrTest::member_item< bi::bs_set_member_hook<> > member_item_type; + + template + struct get_key + { + typedef T type; + + type const& operator()( Node const& v ) const + { + return v.nKey; + } + }; } +#if BOOST_VERSION >= 105900 +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>> +#else +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) +#endif + + void IntrusiveStripedSetHdrTest::Striped_sg_set_basehook() { typedef ci::StripedSet< - bi::sg_set > > + bi::sg_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::mutex_policy< ci::striped_set::striping<> > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > > set_type; @@ -26,7 +47,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Striped_sg_set_basehook_bucket_threshold() { typedef ci::StripedSet< - bi::sg_set > > + bi::sg_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> > > set_type; @@ -37,7 +61,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Striped_sg_set_basehook_bucket_threshold_rt() { typedef ci::StripedSet< - bi::sg_set > > + bi::sg_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > > set_type; @@ -53,6 +80,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > > set_type; @@ -67,6 +95,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > @@ -82,6 +111,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > diff --git a/tests/test-hdr/set/hdr_intrusive_striped_hashset_splayset.cpp b/tests/test-hdr/set/hdr_intrusive_striped_hashset_splayset.cpp index 3601a489..8a3ffdc8 100644 --- a/tests/test-hdr/set/hdr_intrusive_striped_hashset_splayset.cpp +++ b/tests/test-hdr/set/hdr_intrusive_striped_hashset_splayset.cpp @@ -19,12 +19,33 @@ namespace set { typedef IntrusiveStripedSetHdrTest::base_item< splay_set_base_hook> base_item_type; typedef IntrusiveStripedSetHdrTest::member_item< splay_set_member_hook > member_item_type; + + template + struct get_key + { + typedef T type; + + type const& operator()( Node const& v ) const + { + return v.nKey; + } + }; } +#if BOOST_VERSION >= 105900 +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>> +#else +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) +#endif + + void IntrusiveStripedSetHdrTest::Striped_splay_set_basehook() { typedef ci::StripedSet< - bi::splay_set > > + bi::splay_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::mutex_policy< ci::striped_set::striping<> > > set_type; @@ -35,7 +56,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Striped_splay_set_basehook_bucket_threshold() { typedef ci::StripedSet< - bi::splay_set > > + bi::splay_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> > > set_type; @@ -46,7 +70,10 @@ namespace set { void IntrusiveStripedSetHdrTest::Striped_splay_set_basehook_bucket_threshold_rt() { typedef ci::StripedSet< - bi::splay_set > > + bi::splay_set> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > > set_type; @@ -62,6 +89,7 @@ namespace set { member_item_type , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember> , bi::compare > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > > set_type; @@ -75,7 +103,8 @@ namespace set { bi::splay_set< member_item_type , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember> - , bi::compare > + , bi::compare> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > @@ -90,7 +119,8 @@ namespace set { bi::splay_set< member_item_type , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember> - , bi::compare > + , bi::compare> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > diff --git a/tests/test-hdr/set/hdr_intrusive_striped_hashset_treapset.cpp b/tests/test-hdr/set/hdr_intrusive_striped_hashset_treapset.cpp index cfda70fc..0ded224b 100644 --- a/tests/test-hdr/set/hdr_intrusive_striped_hashset_treapset.cpp +++ b/tests/test-hdr/set/hdr_intrusive_striped_hashset_treapset.cpp @@ -22,12 +22,33 @@ namespace set { return base_class::operator()( b, a ); } }; + + template + struct get_key + { + typedef T type; + + type const& operator()( Node const& v ) const + { + return v.nKey; + } + }; } +#if BOOST_VERSION >= 105900 +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>> +#else +# define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) +#endif + void IntrusiveStripedSetHdrTest::Striped_treap_set_basehook() { typedef ci::StripedSet< - bi::treap_set >, bi::priority > > + bi::treap_set < base_item_type, + bi::compare>, + bi::priority> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::mutex_policy< ci::striped_set::striping<> > > set_type; @@ -38,7 +59,11 @@ namespace set { void IntrusiveStripedSetHdrTest::Striped_treap_set_basehook_bucket_threshold() { typedef ci::StripedSet< - bi::treap_set >, bi::priority > > + bi::treap_set >, + bi::priority> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> > > set_type; @@ -49,7 +74,11 @@ namespace set { void IntrusiveStripedSetHdrTest::Striped_treap_set_basehook_bucket_threshold_rt() { typedef ci::StripedSet< - bi::treap_set >, bi::priority > > + bi::treap_set>, + bi::priority> + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type ) + > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > > set_type; @@ -66,6 +95,7 @@ namespace set { , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > , bi::priority > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > > set_type; @@ -81,6 +111,7 @@ namespace set { , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > , bi::priority > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> > @@ -97,6 +128,7 @@ namespace set { , bi::member_hook< member_item_type, bi::bs_set_member_hook<>, &member_item_type::hMember> , bi::compare > , bi::priority > + CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type ) > ,co::hash< IntrusiveStripedSetHdrTest::hash_int > ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> > diff --git a/tests/test-hdr/set/hdr_intrusive_striped_set.h b/tests/test-hdr/set/hdr_intrusive_striped_set.h index a67f99cd..c0218f5a 100644 --- a/tests/test-hdr/set/hdr_intrusive_striped_set.h +++ b/tests/test-hdr/set/hdr_intrusive_striped_set.h @@ -47,6 +47,11 @@ namespace set { item() {} + explicit item( int key ) + : nKey( key ) + , nVal(0) + {} + item(int key, int val) : nKey( key ) , nVal(val) @@ -78,6 +83,10 @@ namespace set { base_item() {} + explicit base_item( int key ) + : item( key ) + {} + base_item(int key, int val) : item( key, val ) {} @@ -86,6 +95,11 @@ namespace set { : item( static_cast(v) ) , stat() {} + + operator int() const + { + return key(); + } }; template @@ -98,6 +112,10 @@ namespace set { member_item() {} + explicit member_item( int key ) + : item( key ) + {} + member_item(int key, int val) : item( key, val ) {} @@ -106,6 +124,11 @@ namespace set { : item( static_cast(v)) , stat() {} + + operator int() const + { + return key(); + } }; struct find_key { @@ -151,6 +174,11 @@ namespace set { { return v1 < v2.key(); } + + bool operator()( int i1, int i2 ) const + { + return i1 < i2; + } }; template @@ -232,26 +260,39 @@ namespace set { } }; + template + struct get_int_key + { + int operator()( T const & v ) const + { + return v.key(); + } + }; + + template <> + struct get_int_key + { + int operator()( int i ) const + { + return i; + } + }; + struct less2 { template bool operator()( Item const& e, find_key const& k ) const { - return e.key() < k.nKey; + return get_int_key()(e) < k.nKey; } template bool operator()( find_key const& k, Item const& e ) const { - return k.nKey < e.key(); + return k.nKey < get_int_key()(e); } - template - bool operator()( Item const& e, int k ) const - { - return e.key() < k; - } - template - bool operator()( int k, Item const& e ) const + template + bool operator()( Item1 const& e, Item2 const& k ) const { - return k < e.key(); + return get_int_key()(e) < get_int_key()(k); } }; -- 2.34.1