annotate DEPENDENCIES/generic/include/boost/intrusive/any_hook.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 /////////////////////////////////////////////////////////////////////////////
Chris@16 2 //
Chris@16 3 // (C) Copyright Ion Gaztanaga 2006-2013
Chris@16 4 //
Chris@16 5 // Distributed under the Boost Software License, Version 1.0.
Chris@16 6 // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 //
Chris@16 9 // See http://www.boost.org/libs/intrusive for documentation.
Chris@16 10 //
Chris@16 11 /////////////////////////////////////////////////////////////////////////////
Chris@16 12
Chris@16 13 #ifndef BOOST_INTRUSIVE_ANY_HOOK_HPP
Chris@16 14 #define BOOST_INTRUSIVE_ANY_HOOK_HPP
Chris@16 15
Chris@16 16 #include <boost/intrusive/detail/config_begin.hpp>
Chris@16 17 #include <boost/intrusive/intrusive_fwd.hpp>
Chris@16 18 #include <boost/intrusive/detail/utilities.hpp>
Chris@16 19 #include <boost/intrusive/detail/any_node_and_algorithms.hpp>
Chris@16 20 #include <boost/intrusive/options.hpp>
Chris@16 21 #include <boost/intrusive/detail/generic_hook.hpp>
Chris@16 22 #include <boost/intrusive/pointer_traits.hpp>
Chris@16 23
Chris@16 24 namespace boost {
Chris@16 25 namespace intrusive {
Chris@16 26
Chris@16 27 /// @cond
Chris@16 28 template<class VoidPointer>
Chris@16 29 struct get_any_node_algo
Chris@16 30 {
Chris@16 31 typedef any_algorithms<VoidPointer> type;
Chris@16 32 };
Chris@16 33 /// @endcond
Chris@16 34
Chris@16 35 //! Helper metafunction to define a \c \c any_base_hook that yields to the same
Chris@16 36 //! type when the same options (either explicitly or implicitly) are used.
Chris@16 37 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 38 template<class ...Options>
Chris@16 39 #else
Chris@16 40 template<class O1 = void, class O2 = void, class O3 = void>
Chris@16 41 #endif
Chris@16 42 struct make_any_base_hook
Chris@16 43 {
Chris@16 44 /// @cond
Chris@16 45 typedef typename pack_options
Chris@16 46 < hook_defaults,
Chris@16 47 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 48 O1, O2, O3
Chris@16 49 #else
Chris@16 50 Options...
Chris@16 51 #endif
Chris@16 52 >::type packed_options;
Chris@16 53
Chris@16 54 typedef generic_hook
Chris@16 55 < get_any_node_algo<typename packed_options::void_pointer>
Chris@16 56 , typename packed_options::tag
Chris@16 57 , packed_options::link_mode
Chris@16 58 , AnyBaseHookId
Chris@16 59 > implementation_defined;
Chris@16 60 /// @endcond
Chris@16 61 typedef implementation_defined type;
Chris@16 62 };
Chris@16 63
Chris@16 64 //! Derive a class from this hook in order to store objects of that class
Chris@16 65 //! in an intrusive container.
Chris@16 66 //!
Chris@16 67 //! The hook admits the following options: \c tag<>, \c void_pointer<> and
Chris@16 68 //! \c link_mode<>.
Chris@16 69 //!
Chris@16 70 //! \c tag<> defines a tag to identify the node.
Chris@16 71 //! The same tag value can be used in different classes, but if a class is
Chris@16 72 //! derived from more than one \c any_base_hook, then each \c any_base_hook needs its
Chris@16 73 //! unique tag.
Chris@16 74 //!
Chris@16 75 //! \c link_mode<> will specify the linking mode of the hook (\c normal_link, \c safe_link).
Chris@16 76 //!
Chris@16 77 //! \c void_pointer<> is the pointer type that will be used internally in the hook
Chris@16 78 //! and the the container configured to use this hook.
Chris@16 79 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 80 template<class ...Options>
Chris@16 81 #else
Chris@16 82 template<class O1, class O2, class O3>
Chris@16 83 #endif
Chris@16 84 class any_base_hook
Chris@16 85 : public make_any_base_hook
Chris@16 86 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 87 <O1, O2, O3>
Chris@16 88 #else
Chris@16 89 <Options...>
Chris@16 90 #endif
Chris@16 91 ::type
Chris@16 92 {
Chris@16 93 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
Chris@16 94 public:
Chris@16 95 //! <b>Effects</b>: If link_mode is or \c safe_link
Chris@16 96 //! initializes the node to an unlinked state.
Chris@16 97 //!
Chris@16 98 //! <b>Throws</b>: Nothing.
Chris@16 99 any_base_hook();
Chris@16 100
Chris@16 101 //! <b>Effects</b>: If link_mode is or \c safe_link
Chris@16 102 //! initializes the node to an unlinked state. The argument is ignored.
Chris@16 103 //!
Chris@16 104 //! <b>Throws</b>: Nothing.
Chris@16 105 //!
Chris@16 106 //! <b>Rationale</b>: Providing a copy-constructor
Chris@16 107 //! makes classes using the hook STL-compliant without forcing the
Chris@16 108 //! user to do some additional work. \c swap can be used to emulate
Chris@16 109 //! move-semantics.
Chris@16 110 any_base_hook(const any_base_hook& );
Chris@16 111
Chris@16 112 //! <b>Effects</b>: Empty function. The argument is ignored.
Chris@16 113 //!
Chris@16 114 //! <b>Throws</b>: Nothing.
Chris@16 115 //!
Chris@16 116 //! <b>Rationale</b>: Providing an assignment operator
Chris@16 117 //! makes classes using the hook STL-compliant without forcing the
Chris@16 118 //! user to do some additional work. \c swap can be used to emulate
Chris@16 119 //! move-semantics.
Chris@16 120 any_base_hook& operator=(const any_base_hook& );
Chris@16 121
Chris@16 122 //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
Chris@16 123 //! nothing (ie. no code is generated). If link_mode is \c safe_link and the
Chris@16 124 //! object is stored in a container an assertion is raised.
Chris@16 125 //!
Chris@16 126 //! <b>Throws</b>: Nothing.
Chris@16 127 ~any_base_hook();
Chris@16 128
Chris@16 129 //! <b>Precondition</b>: link_mode must be \c safe_link.
Chris@16 130 //!
Chris@16 131 //! <b>Returns</b>: true, if the node belongs to a container, false
Chris@16 132 //! otherwise. This function can be used to test whether \c container::iterator_to
Chris@16 133 //! will return a valid iterator.
Chris@16 134 //!
Chris@16 135 //! <b>Complexity</b>: Constant
Chris@16 136 bool is_linked() const;
Chris@16 137 #endif
Chris@16 138 };
Chris@16 139
Chris@16 140 //! Helper metafunction to define a \c \c any_member_hook that yields to the same
Chris@16 141 //! type when the same options (either explicitly or implicitly) are used.
Chris@16 142 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 143 template<class ...Options>
Chris@16 144 #else
Chris@16 145 template<class O1 = void, class O2 = void, class O3 = void>
Chris@16 146 #endif
Chris@16 147 struct make_any_member_hook
Chris@16 148 {
Chris@16 149 /// @cond
Chris@16 150 typedef typename pack_options
Chris@16 151 < hook_defaults,
Chris@16 152 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 153 O1, O2, O3
Chris@16 154 #else
Chris@16 155 Options...
Chris@16 156 #endif
Chris@16 157 >::type packed_options;
Chris@16 158
Chris@16 159 typedef generic_hook
Chris@16 160 < get_any_node_algo<typename packed_options::void_pointer>
Chris@16 161 , member_tag
Chris@16 162 , packed_options::link_mode
Chris@16 163 , NoBaseHookId
Chris@16 164 > implementation_defined;
Chris@16 165 /// @endcond
Chris@16 166 typedef implementation_defined type;
Chris@16 167 };
Chris@16 168
Chris@16 169 //! Store this hook in a class to be inserted
Chris@16 170 //! in an intrusive container.
Chris@16 171 //!
Chris@16 172 //! The hook admits the following options: \c void_pointer<> and
Chris@16 173 //! \c link_mode<>.
Chris@16 174 //!
Chris@16 175 //! \c link_mode<> will specify the linking mode of the hook (\c normal_link or \c safe_link).
Chris@16 176 //!
Chris@16 177 //! \c void_pointer<> is the pointer type that will be used internally in the hook
Chris@16 178 //! and the the container configured to use this hook.
Chris@16 179 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED) || defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 180 template<class ...Options>
Chris@16 181 #else
Chris@16 182 template<class O1, class O2, class O3>
Chris@16 183 #endif
Chris@16 184 class any_member_hook
Chris@16 185 : public make_any_member_hook
Chris@16 186 #if !defined(BOOST_INTRUSIVE_VARIADIC_TEMPLATES)
Chris@16 187 <O1, O2, O3>
Chris@16 188 #else
Chris@16 189 <Options...>
Chris@16 190 #endif
Chris@16 191 ::type
Chris@16 192 {
Chris@16 193 #if defined(BOOST_INTRUSIVE_DOXYGEN_INVOKED)
Chris@16 194 public:
Chris@16 195 //! <b>Effects</b>: If link_mode is or \c safe_link
Chris@16 196 //! initializes the node to an unlinked state.
Chris@16 197 //!
Chris@16 198 //! <b>Throws</b>: Nothing.
Chris@16 199 any_member_hook();
Chris@16 200
Chris@16 201 //! <b>Effects</b>: If link_mode is or \c safe_link
Chris@16 202 //! initializes the node to an unlinked state. The argument is ignored.
Chris@16 203 //!
Chris@16 204 //! <b>Throws</b>: Nothing.
Chris@16 205 //!
Chris@16 206 //! <b>Rationale</b>: Providing a copy-constructor
Chris@16 207 //! makes classes using the hook STL-compliant without forcing the
Chris@16 208 //! user to do some additional work. \c swap can be used to emulate
Chris@16 209 //! move-semantics.
Chris@16 210 any_member_hook(const any_member_hook& );
Chris@16 211
Chris@16 212 //! <b>Effects</b>: Empty function. The argument is ignored.
Chris@16 213 //!
Chris@16 214 //! <b>Throws</b>: Nothing.
Chris@16 215 //!
Chris@16 216 //! <b>Rationale</b>: Providing an assignment operator
Chris@16 217 //! makes classes using the hook STL-compliant without forcing the
Chris@16 218 //! user to do some additional work. \c swap can be used to emulate
Chris@16 219 //! move-semantics.
Chris@16 220 any_member_hook& operator=(const any_member_hook& );
Chris@16 221
Chris@16 222 //! <b>Effects</b>: If link_mode is \c normal_link, the destructor does
Chris@16 223 //! nothing (ie. no code is generated). If link_mode is \c safe_link and the
Chris@16 224 //! object is stored in a container an assertion is raised.
Chris@16 225 //!
Chris@16 226 //! <b>Throws</b>: Nothing.
Chris@16 227 ~any_member_hook();
Chris@16 228
Chris@16 229 //! <b>Precondition</b>: link_mode must be \c safe_link.
Chris@16 230 //!
Chris@16 231 //! <b>Returns</b>: true, if the node belongs to a container, false
Chris@16 232 //! otherwise. This function can be used to test whether \c container::iterator_to
Chris@16 233 //! will return a valid iterator.
Chris@16 234 //!
Chris@16 235 //! <b>Complexity</b>: Constant
Chris@16 236 bool is_linked() const;
Chris@16 237 #endif
Chris@16 238 };
Chris@16 239
Chris@16 240 /// @cond
Chris@16 241
Chris@16 242 namespace detail{
Chris@16 243
Chris@16 244 template<class ValueTraits>
Chris@16 245 struct any_to_get_base_pointer_type
Chris@16 246 {
Chris@16 247 typedef typename pointer_traits<typename ValueTraits::hooktags::node_traits::node_ptr>::template
Chris@16 248 rebind_pointer<void>::type type;
Chris@16 249 };
Chris@16 250
Chris@16 251 template<class ValueTraits>
Chris@16 252 struct any_to_get_member_pointer_type
Chris@16 253 {
Chris@16 254 typedef typename pointer_traits
Chris@16 255 <typename ValueTraits::node_ptr>::template rebind_pointer<void>::type type;
Chris@16 256 };
Chris@16 257
Chris@16 258 //!This option setter specifies that the container
Chris@16 259 //!must use the specified base hook
Chris@16 260 template<class BaseHook, template <class> class NodeTraits>
Chris@16 261 struct any_to_some_hook
Chris@16 262 {
Chris@16 263 typedef typename BaseHook::template pack<empty>::proto_value_traits old_proto_value_traits;
Chris@16 264
Chris@16 265 template<class Base>
Chris@16 266 struct pack : public Base
Chris@16 267 {
Chris@16 268 struct proto_value_traits : public old_proto_value_traits
Chris@16 269 {
Chris@16 270 static const bool is_any_hook = true;
Chris@16 271 typedef typename detail::eval_if_c
Chris@16 272 < detail::internal_base_hook_bool_is_true<old_proto_value_traits>::value
Chris@16 273 , any_to_get_base_pointer_type<old_proto_value_traits>
Chris@16 274 , any_to_get_member_pointer_type<old_proto_value_traits>
Chris@16 275 >::type void_pointer;
Chris@16 276 typedef NodeTraits<void_pointer> node_traits;
Chris@16 277 };
Chris@16 278 };
Chris@16 279 };
Chris@16 280
Chris@16 281 } //namespace detail{
Chris@16 282
Chris@16 283 /// @endcond
Chris@16 284
Chris@16 285 //!This option setter specifies that
Chris@16 286 //!any hook should behave as an slist hook
Chris@16 287 template<class BaseHook>
Chris@16 288 struct any_to_slist_hook
Chris@16 289 /// @cond
Chris@16 290 : public detail::any_to_some_hook<BaseHook, any_slist_node_traits>
Chris@16 291 /// @endcond
Chris@16 292 {};
Chris@16 293
Chris@16 294 //!This option setter specifies that
Chris@16 295 //!any hook should behave as an list hook
Chris@16 296 template<class BaseHook>
Chris@16 297 struct any_to_list_hook
Chris@16 298 /// @cond
Chris@16 299 : public detail::any_to_some_hook<BaseHook, any_list_node_traits>
Chris@16 300 /// @endcond
Chris@16 301 {};
Chris@16 302
Chris@16 303 //!This option setter specifies that
Chris@16 304 //!any hook should behave as a set hook
Chris@16 305 template<class BaseHook>
Chris@16 306 struct any_to_set_hook
Chris@16 307 /// @cond
Chris@16 308 : public detail::any_to_some_hook<BaseHook, any_rbtree_node_traits>
Chris@16 309 /// @endcond
Chris@16 310 {};
Chris@16 311
Chris@16 312 //!This option setter specifies that
Chris@16 313 //!any hook should behave as an avl_set hook
Chris@16 314 template<class BaseHook>
Chris@16 315 struct any_to_avl_set_hook
Chris@16 316 /// @cond
Chris@16 317 : public detail::any_to_some_hook<BaseHook, any_avltree_node_traits>
Chris@16 318 /// @endcond
Chris@16 319 {};
Chris@16 320
Chris@16 321 //!This option setter specifies that any
Chris@16 322 //!hook should behave as a bs_set hook
Chris@16 323 template<class BaseHook>
Chris@16 324 struct any_to_bs_set_hook
Chris@16 325 /// @cond
Chris@16 326 : public detail::any_to_some_hook<BaseHook, any_tree_node_traits>
Chris@16 327 /// @endcond
Chris@16 328 {};
Chris@16 329
Chris@16 330 //!This option setter specifies that any hook
Chris@16 331 //!should behave as an unordered set hook
Chris@16 332 template<class BaseHook>
Chris@16 333 struct any_to_unordered_set_hook
Chris@16 334 /// @cond
Chris@16 335 : public detail::any_to_some_hook<BaseHook, any_unordered_node_traits>
Chris@16 336 /// @endcond
Chris@16 337 {};
Chris@16 338
Chris@16 339
Chris@16 340 } //namespace intrusive
Chris@16 341 } //namespace boost
Chris@16 342
Chris@16 343 #include <boost/intrusive/detail/config_end.hpp>
Chris@16 344
Chris@16 345 #endif //BOOST_INTRUSIVE_ANY_HOOK_HPP