trivial_value_traits.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2006-2013
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/intrusive for documentation.
  10. //
  11. /////////////////////////////////////////////////////////////////////////////
  12. #ifndef BOOST_INTRUSIVE_TRIVIAL_VALUE_TRAITS_HPP
  13. #define BOOST_INTRUSIVE_TRIVIAL_VALUE_TRAITS_HPP
  14. #include <boost/intrusive/detail/config_begin.hpp>
  15. #include <boost/intrusive/detail/workaround.hpp>
  16. #include <boost/intrusive/intrusive_fwd.hpp>
  17. #include <boost/intrusive/link_mode.hpp>
  18. #include <boost/intrusive/pointer_traits.hpp>
  19. #if defined(BOOST_HAS_PRAGMA_ONCE)
  20. # pragma once
  21. #endif
  22. namespace boost {
  23. namespace intrusive {
  24. //!This value traits template is used to create value traits
  25. //!from user defined node traits where value_traits::value_type and
  26. //!node_traits::node should be equal
  27. template<class NodeTraits, link_mode_type LinkMode
  28. #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
  29. = safe_link
  30. #endif
  31. >
  32. struct trivial_value_traits
  33. {
  34. typedef NodeTraits node_traits;
  35. typedef typename node_traits::node_ptr node_ptr;
  36. typedef typename node_traits::const_node_ptr const_node_ptr;
  37. typedef typename node_traits::node value_type;
  38. typedef node_ptr pointer;
  39. typedef const_node_ptr const_pointer;
  40. static const link_mode_type link_mode = LinkMode;
  41. BOOST_INTRUSIVE_FORCEINLINE static node_ptr to_node_ptr (value_type &value)
  42. { return pointer_traits<node_ptr>::pointer_to(value); }
  43. BOOST_INTRUSIVE_FORCEINLINE static const_node_ptr to_node_ptr (const value_type &value)
  44. { return pointer_traits<const_node_ptr>::pointer_to(value); }
  45. BOOST_INTRUSIVE_FORCEINLINE static const pointer & to_value_ptr(const node_ptr &n) { return n; }
  46. BOOST_INTRUSIVE_FORCEINLINE static const const_pointer &to_value_ptr(const const_node_ptr &n) { return n; }
  47. };
  48. } //namespace intrusive
  49. } //namespace boost
  50. #include <boost/intrusive/detail/config_end.hpp>
  51. #endif //BOOST_INTRUSIVE_TRIVIAL_VALUE_TRAITS_HPP