trivial_value_traits.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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) BOOST_NOEXCEPT
  42. { return pointer_traits<node_ptr>::pointer_to(value); }
  43. BOOST_INTRUSIVE_FORCEINLINE static const_node_ptr to_node_ptr (const value_type &value) BOOST_NOEXCEPT
  44. { return pointer_traits<const_node_ptr>::pointer_to(value); }
  45. BOOST_INTRUSIVE_FORCEINLINE static pointer to_value_ptr(node_ptr n) BOOST_NOEXCEPT
  46. { return n; }
  47. BOOST_INTRUSIVE_FORCEINLINE static const_pointer to_value_ptr(const_node_ptr n) BOOST_NOEXCEPT
  48. { return n; }
  49. };
  50. } //namespace intrusive
  51. } //namespace boost
  52. #include <boost/intrusive/detail/config_end.hpp>
  53. #endif //BOOST_INTRUSIVE_TRIVIAL_VALUE_TRAITS_HPP