Fixed compatibility with boost 1.59 for striped intrusive sets
[libcds.git] / tests / test-hdr / set / hdr_intrusive_striped_hashset_set.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_striped_set.h"
4 #include <cds/intrusive/striped_set/boost_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::set_base_hook<> > base_item_type;
12         typedef IntrusiveStripedSetHdrTest::member_item< bi::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
33     void IntrusiveStripedSetHdrTest::Striped_set_basehook()
34     {
35         typedef ci::StripedSet<
36             bi::set<base_item_type
37                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
38                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
39             >
40             ,co::mutex_policy< ci::striped_set::striping<> >
41             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
42         > set_type;
43
44         test<set_type>();
45     }
46
47     void IntrusiveStripedSetHdrTest::Striped_set_basehook_bucket_threshold()
48     {
49         typedef ci::StripedSet<
50             bi::set<base_item_type
51                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type>>
52                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
53             >
54             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
55             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<64> >
56         > set_type;
57
58         test<set_type>();
59     }
60
61     void IntrusiveStripedSetHdrTest::Striped_set_basehook_bucket_threshold_rt()
62     {
63         typedef ci::StripedSet<
64             bi::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         > set_type;
71
72         set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );
73         test_with( s );
74     }
75
76     void IntrusiveStripedSetHdrTest::Striped_set_memberhook()
77     {
78         typedef ci::StripedSet<
79             bi::set<
80                 member_item_type
81                 , bi::member_hook< member_item_type, bi::set_member_hook<>, &member_item_type::hMember>
82                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
83                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
84             >
85             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
86         > set_type;
87
88         test<set_type>();
89     }
90
91     void IntrusiveStripedSetHdrTest::Striped_set_memberhook_bucket_threshold()
92     {
93         typedef ci::StripedSet<
94             bi::set<
95                 member_item_type
96                 , bi::member_hook< member_item_type, bi::set_member_hook<>, &member_item_type::hMember>
97                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
98                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
99             >
100             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
101             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
102         > set_type;
103
104         test<set_type>();
105     }
106
107     void IntrusiveStripedSetHdrTest::Striped_set_memberhook_bucket_threshold_rt()
108     {
109         typedef ci::StripedSet<
110             bi::set<
111                 member_item_type
112                 , bi::member_hook< member_item_type, bi::set_member_hook<>, &member_item_type::hMember>
113                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
114                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
115             >
116             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
117             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
118         > set_type;
119
120         set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );
121         test_with( s );
122     }
123
124 } // namespace set
125
126