Fixed explicit ctor incompatibility
[libcds.git] / tests / test-hdr / map / hdr_splitlist_map_hp.cpp
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
5
6     Source code repo: http://github.com/khizmax/libcds/
7     Download: http://sourceforge.net/projects/libcds/files/
8     
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions are met:
11
12     * Redistributions of source code must retain the above copyright notice, this
13       list of conditions and the following disclaimer.
14
15     * Redistributions in binary form must reproduce the above copyright notice,
16       this list of conditions and the following disclaimer in the documentation
17       and/or other materials provided with the distribution.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
29 */
30
31 #include "map/hdr_map.h"
32 #include <cds/container/michael_list_hp.h>
33 #include <cds/container/split_list_map.h>
34
35 namespace map {
36
37     namespace {
38         struct HP_cmp_traits: public cc::split_list::traits
39         {
40             typedef cc::michael_list_tag                ordered_list;
41             typedef HashMapHdrTest::hash_int            hash;
42             typedef HashMapHdrTest::simple_item_counter item_counter;
43             typedef cc::opt::v::relaxed_ordering        memory_model;
44             enum { dynamic_bucket_table = false };
45
46             struct ordered_list_traits: public cc::michael_list::traits
47             {
48                 typedef HashMapHdrTest::cmp   compare;
49             };
50         };
51
52         struct HP_less_traits: public cc::split_list::traits
53         {
54             typedef cc::michael_list_tag                ordered_list;
55             typedef HashMapHdrTest::hash_int            hash;
56             typedef HashMapHdrTest::simple_item_counter item_counter;
57             typedef cc::opt::v::sequential_consistent                      memory_model;
58             enum { dynamic_bucket_table = false };
59
60             struct ordered_list_traits: public cc::michael_list::traits
61             {
62                 typedef HashMapHdrTest::less   less;
63             };
64         };
65
66         struct HP_cmpmix_traits: public cc::split_list::traits
67         {
68             typedef cc::michael_list_tag                ordered_list;
69             typedef HashMapHdrTest::hash_int            hash;
70             typedef HashMapHdrTest::simple_item_counter item_counter;
71
72             struct ordered_list_traits: public cc::michael_list::traits
73             {
74                 typedef HashMapHdrTest::cmp   compare;
75                 typedef std::less<HashMapHdrTest::key_type>     less;
76             };
77         };
78
79         struct HP_cmpmix_stat_traits : public HP_cmpmix_traits
80         {
81             typedef cc::split_list::stat<> stat;
82         };
83
84     }
85
86     void HashMapHdrTest::Split_HP_cmp()
87     {
88         // traits-based version
89         typedef cc::SplitListMap< cds::gc::HP, key_type, value_type, HP_cmp_traits > map_type;
90         test_int< map_type >();
91
92         // option-based version
93         typedef cc::SplitListMap< cds::gc::HP,
94             key_type,
95             value_type,
96             cc::split_list::make_traits<
97                 cc::split_list::ordered_list<cc::michael_list_tag>
98                 ,cc::opt::hash< hash_int >
99                 ,cc::opt::item_counter< simple_item_counter >
100                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
101                 ,cc::split_list::dynamic_bucket_table< true >
102                 ,cc::split_list::ordered_list_traits<
103                     cc::michael_list::make_traits<
104                         cc::opt::compare< cmp >
105                     >::type
106                 >
107             >::type
108         > opt_map;
109         test_int< opt_map >();
110     }
111
112     void HashMapHdrTest::Split_HP_less()
113     {
114         // traits-based version
115         typedef cc::SplitListMap< cds::gc::HP, key_type, value_type, HP_less_traits > map_type;
116         test_int< map_type >();
117
118         // option-based version
119         typedef cc::SplitListMap< cds::gc::HP,
120             key_type,
121             value_type,
122             cc::split_list::make_traits<
123                 cc::split_list::ordered_list<cc::michael_list_tag>
124                 ,cc::opt::hash< hash_int >
125                 ,cc::opt::item_counter< simple_item_counter >
126                 ,cc::opt::memory_model< cc::opt::v::relaxed_ordering >
127                 ,cc::split_list::dynamic_bucket_table< true >
128                 ,cc::split_list::ordered_list_traits<
129                     cc::michael_list::make_traits<
130                         cc::opt::less< less >
131                     >::type
132                 >
133             >::type
134         > opt_map;
135         test_int< opt_map >();
136     }
137
138     void HashMapHdrTest::Split_HP_cmpmix()
139     {
140         // traits-based version
141         typedef cc::SplitListMap< cds::gc::HP, key_type, value_type, HP_cmpmix_traits > map_type;
142         test_int< map_type >();
143
144         // option-based version
145         typedef cc::SplitListMap< cds::gc::HP,
146             key_type,
147             value_type,
148             cc::split_list::make_traits<
149                 cc::split_list::ordered_list<cc::michael_list_tag>
150                 ,cc::opt::hash< hash_int >
151                 ,cc::opt::item_counter< simple_item_counter >
152                 ,cc::split_list::ordered_list_traits<
153                     cc::michael_list::make_traits<
154                     cc::opt::less< std::less<key_type> >
155                         ,cc::opt::compare< cmp >
156                     >::type
157                 >
158             >::type
159         > opt_map;
160         test_int< opt_map >();
161     }
162
163     void HashMapHdrTest::Split_HP_cmpmix_stat()
164     {
165         // traits-based version
166         typedef cc::SplitListMap< cds::gc::HP, key_type, value_type, HP_cmpmix_stat_traits > map_type;
167         test_int< map_type >();
168
169         // option-based version
170         typedef cc::SplitListMap< cds::gc::HP,
171             key_type,
172             value_type,
173             cc::split_list::make_traits<
174                 cc::split_list::ordered_list<cc::michael_list_tag>
175                 ,cc::opt::hash< hash_int >
176                 ,cc::opt::item_counter< simple_item_counter >
177                 ,cc::split_list::ordered_list_traits<
178                     cc::michael_list::make_traits<
179                     cc::opt::less< std::less<key_type> >
180                         ,cc::opt::compare< cmp >
181                     >::type
182                 >
183                 ,cds::opt::stat< cc::split_list::stat<>>
184             >::type
185         > opt_map;
186         test_int< opt_map >();
187     }
188
189 } // namespace map
190