Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/intrusive/detail/generic_hook.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
11 ///////////////////////////////////////////////////////////////////////////// | 11 ///////////////////////////////////////////////////////////////////////////// |
12 | 12 |
13 #ifndef BOOST_INTRUSIVE_GENERIC_HOOK_HPP | 13 #ifndef BOOST_INTRUSIVE_GENERIC_HOOK_HPP |
14 #define BOOST_INTRUSIVE_GENERIC_HOOK_HPP | 14 #define BOOST_INTRUSIVE_GENERIC_HOOK_HPP |
15 | 15 |
16 #include <boost/intrusive/detail/config_begin.hpp> | 16 #ifndef BOOST_CONFIG_HPP |
17 #include <boost/intrusive/intrusive_fwd.hpp> | 17 # include <boost/config.hpp> |
18 #endif | |
19 | |
20 #if defined(BOOST_HAS_PRAGMA_ONCE) | |
21 # pragma once | |
22 #endif | |
23 | |
18 #include <boost/intrusive/pointer_traits.hpp> | 24 #include <boost/intrusive/pointer_traits.hpp> |
19 #include <boost/intrusive/link_mode.hpp> | 25 #include <boost/intrusive/link_mode.hpp> |
20 #include <boost/intrusive/detail/utilities.hpp> | |
21 #include <boost/intrusive/detail/mpl.hpp> | 26 #include <boost/intrusive/detail/mpl.hpp> |
22 #include <boost/intrusive/pointer_traits.hpp> | 27 #include <boost/intrusive/detail/assert.hpp> |
28 #include <boost/intrusive/detail/node_holder.hpp> | |
23 #include <boost/static_assert.hpp> | 29 #include <boost/static_assert.hpp> |
24 | 30 |
25 namespace boost { | 31 namespace boost { |
26 namespace intrusive { | 32 namespace intrusive { |
27 | 33 |
28 /// @cond | 34 /// @cond |
35 | |
36 namespace detail { | |
37 | |
38 template <link_mode_type LinkMode> | |
39 struct link_dispatch | |
40 {}; | |
41 | |
42 template<class Hook> | |
43 void destructor_impl(Hook &hook, detail::link_dispatch<safe_link>) | |
44 { //If this assertion raises, you might have destroyed an object | |
45 //while it was still inserted in a container that is alive. | |
46 //If so, remove the object from the container before destroying it. | |
47 (void)hook; BOOST_INTRUSIVE_SAFE_HOOK_DESTRUCTOR_ASSERT(!hook.is_linked()); | |
48 } | |
49 | |
50 template<class Hook> | |
51 void destructor_impl(Hook &hook, detail::link_dispatch<auto_unlink>) | |
52 { hook.unlink(); } | |
53 | |
54 template<class Hook> | |
55 void destructor_impl(Hook &, detail::link_dispatch<normal_link>) | |
56 {} | |
57 | |
58 } //namespace detail { | |
29 | 59 |
30 enum base_hook_type | 60 enum base_hook_type |
31 { NoBaseHookId | 61 { NoBaseHookId |
32 , ListBaseHookId | 62 , ListBaseHookId |
33 , SlistBaseHookId | 63 , SlistBaseHookId |
34 , RbTreeBaseHookId | 64 , RbTreeBaseHookId |
35 , HashBaseHookId | 65 , HashBaseHookId |
36 , SplayTreeBaseHookId | |
37 , AvlTreeBaseHookId | 66 , AvlTreeBaseHookId |
38 , BsTreeBaseHookId | 67 , BsTreeBaseHookId |
68 , TreapTreeBaseHookId | |
39 , AnyBaseHookId | 69 , AnyBaseHookId |
40 }; | 70 }; |
41 | 71 |
42 | 72 |
43 template <class HookTags, unsigned int> | 73 template <class HookTags, unsigned int> |
56 { typedef HookTags default_rbtree_hook; }; | 86 { typedef HookTags default_rbtree_hook; }; |
57 | 87 |
58 template <class HookTags> | 88 template <class HookTags> |
59 struct hook_tags_definer<HookTags, HashBaseHookId> | 89 struct hook_tags_definer<HookTags, HashBaseHookId> |
60 { typedef HookTags default_hashtable_hook; }; | 90 { typedef HookTags default_hashtable_hook; }; |
61 | |
62 template <class HookTags> | |
63 struct hook_tags_definer<HookTags, SplayTreeBaseHookId> | |
64 { typedef HookTags default_splaytree_hook; }; | |
65 | 91 |
66 template <class HookTags> | 92 template <class HookTags> |
67 struct hook_tags_definer<HookTags, AvlTreeBaseHookId> | 93 struct hook_tags_definer<HookTags, AvlTreeBaseHookId> |
68 { typedef HookTags default_avltree_hook; }; | 94 { typedef HookTags default_avltree_hook; }; |
69 | 95 |
92 }; | 118 }; |
93 | 119 |
94 /// @endcond | 120 /// @endcond |
95 | 121 |
96 template | 122 template |
97 < class GetNodeAlgorithms | 123 < class NodeAlgorithms |
98 , class Tag | 124 , class Tag |
99 , link_mode_type LinkMode | 125 , link_mode_type LinkMode |
100 , base_hook_type BaseHookType | 126 , base_hook_type BaseHookType |
101 > | 127 > |
102 class generic_hook | 128 class generic_hook |
107 // | 133 // |
108 //If the hook is a member hook, generic hook will directly derive | 134 //If the hook is a member hook, generic hook will directly derive |
109 //from the hook. | 135 //from the hook. |
110 : public detail::if_c | 136 : public detail::if_c |
111 < detail::is_same<Tag, member_tag>::value | 137 < detail::is_same<Tag, member_tag>::value |
112 , typename GetNodeAlgorithms::type::node | 138 , typename NodeAlgorithms::node |
113 , node_holder<typename GetNodeAlgorithms::type::node, Tag, BaseHookType> | 139 , node_holder<typename NodeAlgorithms::node, Tag, BaseHookType> |
114 >::type | 140 >::type |
115 //If this is the a default-tagged base hook derive from a class that | 141 //If this is the a default-tagged base hook derive from a class that |
116 //will define an special internal typedef. Containers will be able to detect this | 142 //will define an special internal typedef. Containers will be able to detect this |
117 //special typedef and obtain generic_hook's internal types in order to deduce | 143 //special typedef and obtain generic_hook's internal types in order to deduce |
118 //value_traits for this hook. | 144 //value_traits for this hook. |
119 , public hook_tags_definer | 145 , public hook_tags_definer |
120 < generic_hook<GetNodeAlgorithms, Tag, LinkMode, BaseHookType> | 146 < generic_hook<NodeAlgorithms, Tag, LinkMode, BaseHookType> |
121 , detail::is_same<Tag, default_tag>::value*BaseHookType> | 147 , detail::is_same<Tag, dft_tag>::value*BaseHookType> |
122 /// @endcond | 148 /// @endcond |
123 { | 149 { |
124 /// @cond | 150 /// @cond |
125 typedef typename GetNodeAlgorithms::type node_algorithms; | 151 typedef NodeAlgorithms node_algorithms; |
126 typedef typename node_algorithms::node node; | 152 typedef typename node_algorithms::node node; |
127 typedef typename node_algorithms::node_ptr node_ptr; | 153 typedef typename node_algorithms::node_ptr node_ptr; |
128 typedef typename node_algorithms::const_node_ptr const_node_ptr; | 154 typedef typename node_algorithms::const_node_ptr const_node_ptr; |
129 | 155 |
130 public: | 156 public: |
131 | 157 |
132 typedef hooktags_impl | 158 typedef hooktags_impl |
133 < typename GetNodeAlgorithms::type::node_traits | 159 < typename NodeAlgorithms::node_traits |
134 , Tag, LinkMode, BaseHookType> hooktags; | 160 , Tag, LinkMode, BaseHookType> hooktags; |
135 | 161 |
136 node_ptr this_ptr() | 162 node_ptr this_ptr() |
137 { return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(*this)); } | 163 { return pointer_traits<node_ptr>::pointer_to(static_cast<node&>(*this)); } |
138 | 164 |
179 } | 205 } |
180 | 206 |
181 void unlink() | 207 void unlink() |
182 { | 208 { |
183 BOOST_STATIC_ASSERT(( (int)hooktags::link_mode == (int)auto_unlink )); | 209 BOOST_STATIC_ASSERT(( (int)hooktags::link_mode == (int)auto_unlink )); |
184 node_algorithms::unlink(this->this_ptr()); | 210 node_ptr n(this->this_ptr()); |
185 node_algorithms::init(this->this_ptr()); | 211 if(!node_algorithms::inited(n)){ |
212 node_algorithms::unlink(n); | |
213 node_algorithms::init(n); | |
214 } | |
186 } | 215 } |
187 }; | 216 }; |
188 | 217 |
189 } //namespace intrusive | 218 } //namespace intrusive |
190 } //namespace boost | 219 } //namespace boost |
191 | 220 |
192 #include <boost/intrusive/detail/config_end.hpp> | |
193 | |
194 #endif //BOOST_INTRUSIVE_GENERIC_HOOK_HPP | 221 #endif //BOOST_INTRUSIVE_GENERIC_HOOK_HPP |