Fixed compatibility with boost 1.59 for striped intrusive sets
[libcds.git] / tests / test-hdr / set / hdr_intrusive_striped_hashset_avlset.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_striped_set.h"
4 #include <cds/intrusive/striped_set/boost_avl_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::avl_set_base_hook<> > base_item_type;
12         typedef IntrusiveStripedSetHdrTest::member_item< bi::avl_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::Striped_avl_set_basehook()
33     {
34         typedef ci::StripedSet<
35             bi::avl_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::mutex_policy< ci::striped_set::striping<> >
40             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
41         > set_type;
42
43         test<set_type>();
44     }
45
46     void IntrusiveStripedSetHdrTest::Striped_avl_set_basehook_bucket_threshold()
47     {
48         typedef ci::StripedSet<
49             bi::avl_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         > set_type;
56
57         test<set_type>();
58     }
59
60     void IntrusiveStripedSetHdrTest::Striped_avl_set_basehook_bucket_threshold_rt()
61     {
62         typedef ci::StripedSet<
63             bi::avl_set<base_item_type
64                 , bi::compare<IntrusiveStripedSetHdrTest::less<base_item_type> >
65                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( base_item_type )
66             >
67             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
68             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
69         > set_type;
70
71         set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );
72         test_with( s );
73     }
74
75     void IntrusiveStripedSetHdrTest::Striped_avl_set_memberhook()
76     {
77         typedef ci::StripedSet<
78             bi::avl_set<
79                 member_item_type
80                 , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember>
81                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
82                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
83             >
84             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
85         > set_type;
86
87         test<set_type>();
88     }
89
90     void IntrusiveStripedSetHdrTest::Striped_avl_set_memberhook_bucket_threshold()
91     {
92         typedef ci::StripedSet<
93             bi::avl_set<
94                 member_item_type
95                 , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember>
96                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
97                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
98             >
99             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
100             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<256> >
101         > set_type;
102
103         test<set_type>();
104     }
105
106     void IntrusiveStripedSetHdrTest::Striped_avl_set_memberhook_bucket_threshold_rt()
107     {
108         typedef ci::StripedSet<
109             bi::avl_set<
110                 member_item_type
111                 , bi::member_hook< member_item_type, bi::avl_set_member_hook<>, &member_item_type::hMember>
112                 , bi::compare<IntrusiveStripedSetHdrTest::less<member_item_type> >
113                 CDS_BOOST_INTRUSIVE_KEY_OF_VALUE_OPTION( member_item_type )
114             >
115             ,co::hash< IntrusiveStripedSetHdrTest::hash_int >
116             ,co::resizing_policy< ci::striped_set::single_bucket_size_threshold<0> >
117         > set_type;
118
119         set_type s( 64, ci::striped_set::single_bucket_size_threshold<0>(256) );
120         test_with( s );
121     }
122
123 } // namespace set
124
125