Fix clang 3.4-3.5 64bit build (boost.atomic problem, see https://svn.boost.org/trac...
[libcds.git] / cds / container / split_list_base.h
1 //$$CDS-header$$
2
3 #ifndef __CDS_CONTAINER_SPLIT_LIST_BASE_H
4 #define __CDS_CONTAINER_SPLIT_LIST_BASE_H
5
6 #include <cds/intrusive/split_list_base.h>
7
8 namespace cds { namespace container {
9
10     // forward declaration
11     struct michael_list_tag;
12
13     /// SplitListSet related definitions
14     /** @ingroup cds_nonintrusive_helper
15     */
16     namespace split_list {
17         using intrusive::split_list::dynamic_bucket_table;
18
19         //@cond
20         namespace details {
21
22             template <typename Key, typename Value, typename Traits, typename Opt>
23             struct wrap_map_traits_helper {
24                 typedef Opt key_accessor;
25             };
26
27             template <typename Key, typename Value, typename Traits >
28             struct wrap_map_traits_helper<Key, Value, Traits, opt::none>
29             {
30                 struct key_accessor
31                 {
32                     typedef Key     key_type;
33                     key_type const & operator()( std::pair<Key const, Value> const & val ) const
34                     {
35                         return val.first;
36                     }
37                 };
38             };
39
40             template <typename Key, typename Value, typename Traits>
41             struct wrap_map_traits: public Traits
42             {
43                 typedef typename wrap_map_traits_helper<Key, Value, Traits, typename Traits::key_accessor>::key_accessor    key_accessor;
44             };
45
46             template <typename Value, typename Traits, typename Opt>
47             struct wrap_set_traits_helper {
48                 typedef Opt key_accessor;
49             };
50
51             template <typename Value, typename Traits >
52             struct wrap_set_traits_helper<Value, Traits, opt::none>
53             {
54                 struct key_accessor
55                 {
56                     typedef Value     key_type;
57                     key_type const& operator()( Value const& val ) const
58                     {
59                         return val;
60                     }
61                 };
62             };
63
64             template <typename Value, typename Traits>
65             struct wrap_set_traits: public Traits
66             {
67                 typedef typename wrap_set_traits_helper<Value, Traits, typename Traits::key_accessor>::key_accessor key_accessor;
68             };
69         }  // namespace details
70         //@endcond
71
72
73         /// Type traits for SplitListSet class
74         /**
75             Note, the SplitListSet type traits is based on intrusive::split_list::type_traits.
76             Any member declared in intrusive::split_list::type_traits is also applied to
77             container::split_list::type_traits.
78         */
79         struct type_traits: public intrusive::split_list::type_traits
80         {
81             // Ordered list implementation
82             /**
83                 This option selects appropriate ordered-list implementation for split-list.
84                 It may be \ref michael_list_tag or \ref lazy_list_tag.
85             */
86             typedef michael_list_tag    ordered_list;
87
88             // Ordered list traits
89             /**
90                 With this option you can specify type traits for selected ordered list class.
91                 If this option is opt::none, the ordered list traits is combined with default
92                 ordered list traits and split-list traits.
93
94                 For \p michael_list_tag, the default traits is \ref container::michael_list::type_traits.
95
96                 For \p lazy_list_tag, the default traits is \ref container::lazy_list::type_traits.
97             */
98             typedef opt::none           ordered_list_traits;
99
100             //@cond
101             typedef opt::none           key_accessor;
102             //@endcond
103         };
104
105         /// Option to select ordered list class for split-list
106         /**
107             This option selects appropriate ordered list class for containers based on split-list.
108             Template parameter \p Type may be \ref michael_list_tag or \ref lazy_list_tag.
109         */
110         template <class Type>
111         struct ordered_list
112         {
113             //@cond
114             template<class Base> struct pack: public Base
115             {
116                 typedef Type ordered_list;
117             };
118             //@endcond
119         };
120
121         /// Option to specify ordered list type traits
122         /**
123             The \p Type template parameter specifies ordered list type traits.
124             It depends on type of ordered list selected.
125         */
126         template <class Type>
127         struct ordered_list_traits
128         {
129             //@cond
130             template<class Base> struct pack: public Base
131             {
132                 typedef Type ordered_list_traits;
133             };
134             //@endcond
135         };
136
137         /// Metafunction converting option list to traits struct
138         /**
139             Available \p Options:
140             - split_list::ordered_list - a tag for ordered list implementation.
141                 See split_list::ordered_list for possible values.
142             - split_list::ordered_list_traits - type traits for ordered list implementation.
143                 For MichaelList use container::michael_list::type_traits,
144                 for LazyList use container::lazy_list::type_traits.
145             - plus any option from intrusive::split_list::make_traits
146         */
147         template <typename... Options>
148         struct make_traits {
149             typedef typename cds::opt::make_options< type_traits, Options...>::type type  ;   ///< Result of metafunction
150         };
151     }   // namespace split_list
152
153     //@cond
154     // Forward declarations
155     template <class GC, class T, class Traits = split_list::type_traits>
156     class SplitListSet;
157
158     template <class GC, typename Key, typename Value, class Traits = split_list::type_traits>
159     class SplitListMap;
160     //@endcond
161
162     //@cond
163     // Forward declaration
164     namespace details {
165         template <typename GC, typename T, typename OrderedListTag, typename Traits>
166         struct make_split_list_set;
167
168         template <typename GC, typename Key, typename Value, typename OrderedListTag, typename Traits>
169         struct make_split_list_map;
170     }
171     //@endcond
172
173 }}  // namespace cds::container
174
175
176 #endif // #ifndef __CDS_CONTAINER_SPLIT_LIST_BASE_H