Fixed compiler error
[libcds.git] / cds / container / details / feldman_hashset_base.h
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
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 #ifndef CDSLIB_CONTAINER_DETAILS_FELDMAN_HASHSET_BASE_H
32 #define CDSLIB_CONTAINER_DETAILS_FELDMAN_HASHSET_BASE_H
33
34 #include <cds/intrusive/details/feldman_hashset_base.h>
35 #include <cds/container/details/base.h>
36
37 namespace cds { namespace container {
38     /// \p FeldmanHashSet related definitions
39     /** @ingroup cds_nonintrusive_helper
40     */
41     namespace feldman_hashset {
42         /// Hash accessor option
43         /**
44             @copydetails cds::intrusive::feldman_hashset::traits::hash_accessor
45         */
46         template <typename Accessor>
47         using hash_accessor = cds::intrusive::feldman_hashset::hash_accessor< Accessor >;
48
49         /// Hash size option
50         /**
51             @copydetails cds::intrusive::feldman_hashset::traits::hash_size
52         */
53         template <size_t Size>
54         using hash_size = cds::intrusive::feldman_hashset::hash_size< Size >;
55
56         /// Hash splitter
57         /**
58             @copydetails cds::intrusive::feldman_hashset::traits::hash_splitter
59         */
60         template <typename Splitter>
61         using hash_splitter = cds::intrusive::feldman_hashset::hash_splitter< Splitter >;
62
63         /// \p FeldmanHashSet internal statistics, see cds::intrusive::feldman_hashset::stat
64         template <typename EventCounter = cds::atomicity::event_counter>
65         using stat = cds::intrusive::feldman_hashset::stat< EventCounter >;
66
67         /// \p FeldmanHashSet empty internal statistics
68         typedef cds::intrusive::feldman_hashset::empty_stat empty_stat;
69
70         /// Bit-wise memcmp-based comparator for hash value \p T
71         template <typename T>
72         using bitwise_compare = cds::intrusive::feldman_hashset::bitwise_compare< T >;
73
74         /// \p FeldmanHashSet level statistics
75         typedef cds::intrusive::feldman_hashset::level_statistics level_statistics;
76
77         /// \p FeldmanHashSet traits
78         struct traits
79         {
80             /// Mandatory functor to get hash value from data node
81             /**
82                 @copydetails cds::intrusive::feldman_hashset::traits::hash_accessor
83             */
84             typedef cds::opt::none hash_accessor;
85
86             /// The size of hash value in bytes
87             /**
88                 @copydetails cds::intrusive::feldman_hashset::traits::hash_size
89             */
90             static CDS_CONSTEXPR size_t const hash_size = 0;
91
92             /// Hash splitter
93             /**
94                 @copydetails cds::intrusive::feldman_hashset::traits::hash_splitter
95             */
96             typedef cds::opt::none hash_splitter;
97
98             /// Hash comparing functor
99             /**
100                 @copydetails cds::intrusive::feldman_hashset::traits::compare
101             */
102             typedef cds::opt::none compare;
103
104             /// Specifies binary predicate used for hash compare.
105             /**
106                 @copydetails cds::intrusive::feldman_hashset::traits::less
107             */
108             typedef cds::opt::none less;
109
110             /// Item counter
111             /**
112                 @copydetails cds::intrusive::feldman_hashset::traits::item_counter
113             */
114             typedef cds::atomicity::item_counter item_counter;
115
116             /// Item allocator
117             /**
118                 Default is \ref CDS_DEFAULT_ALLOCATOR
119             */
120             typedef CDS_DEFAULT_ALLOCATOR allocator;
121
122             /// Array node allocator
123             /**
124                 @copydetails cds::intrusive::feldman_hashset::traits::node_allocator
125             */
126             typedef CDS_DEFAULT_ALLOCATOR node_allocator;
127
128             /// C++ memory ordering model
129             /**
130                 @copydetails cds::intrusive::feldman_hashset::traits::memory_model
131             */
132             typedef cds::opt::v::relaxed_ordering memory_model;
133
134             /// Back-off strategy
135             typedef cds::backoff::Default back_off;
136
137             /// Internal statistics
138             /**
139                 @copydetails cds::intrusive::feldman_hashset::traits::stat
140             */
141             typedef empty_stat stat;
142
143             /// RCU deadlock checking policy (only for \ref cds_container_FeldmanHashSet_rcu "RCU-based FeldmanHashSet")
144             /**
145                 @copydetails cds::intrusive::feldman_hashset::traits::rcu_check_deadlock
146             */
147             typedef cds::opt::v::rcu_throw_deadlock rcu_check_deadlock;
148         };
149
150         /// Metafunction converting option list to \p feldman_hashset::traits
151         /**
152             Supported \p Options are:
153             - \p feldman_hashset::hash_accessor - mandatory option, hash accessor functor.
154                 @copydetails traits::hash_accessor
155             - \p feldman_hashset::hash_size - the size of hash value in bytes.
156                 @copydetails traits::hash_size
157             - \p feldman_hashset::hash_splitter - a hash splitter algorithm
158                 @copydetails traits::hash_splitter
159             - \p opt::allocator - item allocator
160                 @copydetails traits::allocator
161             - \p opt::node_allocator - array node allocator.
162                 @copydetails traits::node_allocator
163             - \p opt::compare - hash comparison functor. No default functor is provided.
164                 If the option is not specified, the \p opt::less is used.
165             - \p opt::less - specifies binary predicate used for hash comparison.
166                 @copydetails cds::container::feldman_hashset::traits::less
167             - \p opt::back_off - back-off strategy used. If the option is not specified, the \p cds::backoff::Default is used.
168             - \p opt::item_counter - the type of item counting feature.
169                 @copydetails cds::intrusive::feldman_hashset::traits::item_counter
170             - \p opt::memory_model - C++ memory ordering model. Can be \p opt::v::relaxed_ordering (relaxed memory model, the default)
171                 or \p opt::v::sequential_consistent (sequentially consisnent memory model).
172             - \p opt::stat - internal statistics. By default, it is disabled (\p feldman_hashset::empty_stat).
173                 To enable it use \p feldman_hashset::stat
174             - \p opt::rcu_check_deadlock - a deadlock checking policy for \ref cds_intrusive_FeldmanHashSet_rcu "RCU-based FeldmanHashSet"
175                 Default is \p opt::v::rcu_throw_deadlock
176         */
177         template <typename... Options>
178         struct make_traits
179         {
180 #   ifdef CDS_DOXYGEN_INVOKED
181             typedef implementation_defined type ;   ///< Metafunction result
182 #   else
183             typedef typename cds::opt::make_options<
184                 typename cds::opt::find_type_traits< traits, Options... >::type
185                 ,Options...
186             >::type   type;
187 #   endif
188         };
189     } // namespace feldman_hashset
190
191     //@cond
192     // Forward declaration
193     template < class GC, typename T, class Traits = cds::container::feldman_hashset::traits >
194     class FeldmanHashSet;
195     //@endcond
196
197     //@cond
198     namespace details {
199
200         template <typename GC, typename T, typename Traits>
201         struct make_feldman_hashset
202         {
203             typedef GC      gc;
204             typedef T       value_type;
205             typedef Traits  original_traits;
206
207             typedef cds::details::Allocator< value_type, typename original_traits::allocator > cxx_node_allocator;
208
209             struct node_disposer
210             {
211                 void operator()( value_type * p ) const
212                 {
213                     cxx_node_allocator().Delete( p );
214                 }
215             };
216
217             struct intrusive_traits: public original_traits
218             {
219                 typedef node_disposer disposer;
220             };
221
222             // Metafunction result
223             typedef cds::intrusive::FeldmanHashSet< GC, T, intrusive_traits > type;
224         };
225     } // namespace details
226     //@endcond
227
228 }} // namespace cds::container
229
230 #endif // #ifndef CDSLIB_CONTAINER_DETAILS_FELDMAN_HASHSET_BASE_H