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