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 
13 #ifndef BOOST_INTRUSIVE_TRIVIAL_VALUE_TRAITS_HPP
14 #define BOOST_INTRUSIVE_TRIVIAL_VALUE_TRAITS_HPP
15 
16 #include <boost/intrusive/detail/config_begin.hpp>
17 #include <boost/intrusive/detail/workaround.hpp>
18 #include <boost/intrusive/intrusive_fwd.hpp>
19 #include <boost/intrusive/link_mode.hpp>
20 #include <boost/intrusive/pointer_traits.hpp>
21 
22 #if defined(BOOST_HAS_PRAGMA_ONCE)
23 #  pragma once
24 #endif
25 
26 namespace boost {
27 namespace intrusive {
28 
29 //!This value traits template is used to create value traits
30 //!from user defined node traits where value_traits::value_type and
31 //!node_traits::node should be equal
32 template<class NodeTraits, link_mode_type LinkMode
33    #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
34    = safe_link
35    #endif
36 >
37 struct trivial_value_traits
38 {
39    typedef NodeTraits                                          node_traits;
40    typedef typename node_traits::node_ptr                      node_ptr;
41    typedef typename node_traits::const_node_ptr                const_node_ptr;
42    typedef typename node_traits::node                          value_type;
43    typedef node_ptr                                            pointer;
44    typedef const_node_ptr                                      const_pointer;
45    static const link_mode_type link_mode = LinkMode;
to_node_ptrboost::intrusive::trivial_value_traits46    BOOST_INTRUSIVE_FORCEINLINE static node_ptr       to_node_ptr (value_type &value)
47       {  return pointer_traits<node_ptr>::pointer_to(value);  }
to_node_ptrboost::intrusive::trivial_value_traits48    BOOST_INTRUSIVE_FORCEINLINE static const_node_ptr to_node_ptr (const value_type &value)
49       {  return pointer_traits<const_node_ptr>::pointer_to(value);  }
to_value_ptrboost::intrusive::trivial_value_traits50    BOOST_INTRUSIVE_FORCEINLINE static const pointer  &      to_value_ptr(const node_ptr &n)        {  return n; }
to_value_ptrboost::intrusive::trivial_value_traits51    BOOST_INTRUSIVE_FORCEINLINE static const const_pointer  &to_value_ptr(const const_node_ptr &n)  {  return n; }
52 };
53 
54 } //namespace intrusive
55 } //namespace boost
56 
57 #include <boost/intrusive/detail/config_end.hpp>
58 
59 #endif //BOOST_INTRUSIVE_TRIVIAL_VALUE_TRAITS_HPP
60