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