slist_node.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Olaf Krzikalla 2004-2006.
  4. // (C) Copyright Ion Gaztanaga 2006-2013
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/intrusive for documentation.
  11. //
  12. /////////////////////////////////////////////////////////////////////////////
  13. #ifndef BOOST_INTRUSIVE_SLIST_NODE_HPP
  14. #define BOOST_INTRUSIVE_SLIST_NODE_HPP
  15. #ifndef BOOST_CONFIG_HPP
  16. # include <boost/config.hpp>
  17. #endif
  18. #if defined(BOOST_HAS_PRAGMA_ONCE)
  19. # pragma once
  20. #endif
  21. #include <boost/intrusive/detail/config_begin.hpp>
  22. #include <boost/intrusive/detail/workaround.hpp>
  23. #include <boost/intrusive/pointer_rebind.hpp>
  24. namespace boost {
  25. namespace intrusive {
  26. template<class VoidPointer>
  27. struct slist_node
  28. {
  29. typedef typename pointer_rebind<VoidPointer, slist_node>::type node_ptr;
  30. node_ptr next_;
  31. };
  32. // slist_node_traits can be used with circular_slist_algorithms and supplies
  33. // a slist_node holding the pointers needed for a singly-linked list
  34. // it is used by slist_base_hook and slist_member_hook
  35. template<class VoidPointer>
  36. struct slist_node_traits
  37. {
  38. typedef slist_node<VoidPointer> node;
  39. typedef typename node::node_ptr node_ptr;
  40. typedef typename pointer_rebind<VoidPointer, const node>::type const_node_ptr;
  41. BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const_node_ptr n)
  42. { return n->next_; }
  43. BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(node_ptr n)
  44. { return n->next_; }
  45. BOOST_INTRUSIVE_FORCEINLINE static void set_next(node_ptr n, node_ptr next)
  46. { n->next_ = next; }
  47. };
  48. } //namespace intrusive
  49. } //namespace boost
  50. #include <boost/intrusive/detail/config_end.hpp>
  51. #endif //BOOST_INTRUSIVE_SLIST_NODE_HPP