Fixed compatibility with boost 1.59 for striped intrusive sets
[libcds.git] / tests / test-hdr / set / hdr_intrusive_refinable_hashset_splayset.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_striped_set.h"
4 #include <cds/intrusive/striped_set/boost_splay_set.h>
5 #include <cds/intrusive/striped_set.h>
6 #include <boost/version.hpp>
7
8 namespace set {
9     namespace bi = boost::intrusive;
10
11     namespace {
12 #   if BOOST_VERSION < 105600
13         typedef bi::splay_set_member_hook<> splay_set_member_hook;
14         typedef bi::splay_set_base_hook<> splay_set_base_hook;
15 #else
16         typedef bi::bs_set_base_hook<> splay_set_base_hook;
17         typedef bi::bs_set_member_hook<> splay_set_member_hook;
18 #endif
19         typedef IntrusiveStripedSetHdrTest::base_item< splay_set_base_hook > base_item_type;
20         typedef IntrusiveStripedSetHdrTest::member_item< splay_set_member_hook > member_item_type;
21
22         template <typename T, typename Node>
23         struct get_key
24         {
25             typedef T type;
26
27             type const& operator()( Node const& v ) const
28             {
29                 return v.nKey;
30             }
31         };
32     }
33
34 #if BOOST_VERSION >= 105900
35 #   define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type ) ,bi::key_of_value< get_key< int, type>>
36 #else
37 #   define CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( type )
38 #endif
39
40     void IntrusiveStripedSetHdrTest::Refinable_splay_set_basehook()
41     {
42         typedef ci::StripedSet<
43             bi::splay_set<base_item_type
44                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
45                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
46             >
47             ,co::mutex_policy< ci::striped_set::refinable<> >
48             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
49             ,co::back_off< cds::backoff::empty >
50         > set_type;
51
52         test<set_type>();
53     }
54
55     void IntrusiveStripedSetHdrTest::Refinable_splay_set_basehook_bucket_threshold()
56     {
57         typedef ci::StripedSet<
58             bi::splay_set<base_item_type
59                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
60                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
61             >
62             ,co::mutex_policy< ci::striped_set::refinable<> >
63             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
64             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> >
65         > set_type;
66
67         test<set_type>();
68     }
69
70     void IntrusiveStripedSetHdrTest::Refinable_splay_set_basehook_bucket_threshold_rt()
71     {
72         typedef ci::StripedSet<
73             bi::splay_set<base_item_type
74                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
75                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
76             >
77             ,co::mutex_policy< ci::striped_set::refinable<> >
78             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
79             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
80         > set_type;
81
82         set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );
83         test_with( s );
84     }
85
86     void IntrusiveStripedSetHdrTest::Refinable_splay_set_memberhook()
87     {
88         typedef ci::StripedSet<
89             bi::splay_set<
90                 member_item_type
91                 , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember>
92                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
93                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
94             >
95             ,co::mutex_policy< ci::striped_set::refinable<> >
96             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
97         > set_type;
98
99         test<set_type>();
100     }
101
102     void IntrusiveStripedSetHdrTest::Refinable_splay_set_memberhook_bucket_threshold()
103     {
104         typedef ci::StripedSet<
105             bi::splay_set<
106                 member_item_type
107                 , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember>
108                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
109                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
110             >
111             ,co::mutex_policy< ci::striped_set::refinable<> >
112             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
113             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
114         > set_type;
115
116         test<set_type>();
117     }
118
119     void IntrusiveStripedSetHdrTest::Refinable_splay_set_memberhook_bucket_threshold_rt()
120     {
121         typedef ci::StripedSet<
122             bi::splay_set<
123                 member_item_type
124                 , bi::member_hook< member_item_type, splay_set_member_hook, &member_item_type::hMember>
125                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
126                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
127             >
128             ,co::mutex_policy< ci::striped_set::refinable<> >
129             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
130             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
131         > set_type;
132
133         set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );
134         test_with( s );
135     }
136 } // namespace set
137
138