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