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_DERIVATION_VALUE_TRAITS_HPP
|
Chris@16
|
14 #define BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
|
Chris@16
|
15
|
Chris@101
|
16 #include <boost/intrusive/detail/config_begin.hpp>
|
Chris@101
|
17 #include <boost/intrusive/intrusive_fwd.hpp>
|
Chris@16
|
18 #include <boost/intrusive/link_mode.hpp>
|
Chris@101
|
19 #include <boost/intrusive/pointer_traits.hpp>
|
Chris@101
|
20
|
Chris@101
|
21 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@101
|
22 # pragma once
|
Chris@101
|
23 #endif
|
Chris@16
|
24
|
Chris@16
|
25 namespace boost {
|
Chris@16
|
26 namespace intrusive {
|
Chris@16
|
27
|
Chris@16
|
28 //!This value traits template is used to create value traits
|
Chris@16
|
29 //!from user defined node traits where value_traits::value_type will
|
Chris@16
|
30 //!derive from node_traits::node
|
Chris@101
|
31
|
Chris@101
|
32 template<class T, class NodeTraits, link_mode_type LinkMode
|
Chris@101
|
33 #ifdef BOOST_INTRUSIVE_DOXYGEN_INVOKED
|
Chris@101
|
34 = safe_link
|
Chris@101
|
35 #endif
|
Chris@101
|
36 >
|
Chris@16
|
37 struct derivation_value_traits
|
Chris@16
|
38 {
|
Chris@16
|
39 public:
|
Chris@16
|
40 typedef NodeTraits node_traits;
|
Chris@16
|
41 typedef T value_type;
|
Chris@16
|
42 typedef typename node_traits::node node;
|
Chris@16
|
43 typedef typename node_traits::node_ptr node_ptr;
|
Chris@16
|
44 typedef typename node_traits::const_node_ptr const_node_ptr;
|
Chris@101
|
45 typedef typename pointer_traits<node_ptr>::
|
Chris@101
|
46 template rebind_pointer<value_type>::type pointer;
|
Chris@101
|
47 typedef typename pointer_traits<node_ptr>::
|
Chris@101
|
48 template rebind_pointer<const value_type>::type const_pointer;
|
Chris@16
|
49 typedef typename boost::intrusive::
|
Chris@16
|
50 pointer_traits<pointer>::reference reference;
|
Chris@16
|
51 typedef typename boost::intrusive::
|
Chris@16
|
52 pointer_traits<const_pointer>::reference const_reference;
|
Chris@16
|
53 static const link_mode_type link_mode = LinkMode;
|
Chris@16
|
54
|
Chris@16
|
55 static node_ptr to_node_ptr(reference value)
|
Chris@16
|
56 { return node_ptr(&value); }
|
Chris@16
|
57
|
Chris@16
|
58 static const_node_ptr to_node_ptr(const_reference value)
|
Chris@16
|
59 { return node_ptr(&value); }
|
Chris@16
|
60
|
Chris@16
|
61 static pointer to_value_ptr(const node_ptr &n)
|
Chris@16
|
62 {
|
Chris@101
|
63 return pointer_traits<pointer>::pointer_to(static_cast<reference>(*n));
|
Chris@16
|
64 }
|
Chris@16
|
65
|
Chris@16
|
66 static const_pointer to_value_ptr(const const_node_ptr &n)
|
Chris@16
|
67 {
|
Chris@101
|
68 return pointer_traits<pointer>::pointer_to(static_cast<const_reference>(*n));
|
Chris@16
|
69 }
|
Chris@16
|
70 };
|
Chris@16
|
71
|
Chris@16
|
72 } //namespace intrusive
|
Chris@16
|
73 } //namespace boost
|
Chris@16
|
74
|
Chris@101
|
75 #include <boost/intrusive/detail/config_end.hpp>
|
Chris@101
|
76
|
Chris@16
|
77 #endif //BOOST_INTRUSIVE_DERIVATION_VALUE_TRAITS_HPP
|