]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/intrusive/include/boost/intrusive/detail/default_header_holder.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / intrusive / include / boost / intrusive / detail / default_header_holder.hpp
1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2014-2014
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_DETAIL_DEFAULT_HEADER_HOLDER_HPP
14 #define BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP
15
16 #ifndef BOOST_CONFIG_HPP
17 # include <boost/config.hpp>
18 #endif
19
20 #if defined(BOOST_HAS_PRAGMA_ONCE)
21 # pragma once
22 #endif
23
24 #include <boost/intrusive/detail/workaround.hpp>
25 #include <boost/intrusive/pointer_traits.hpp>
26 #include <boost/intrusive/detail/to_raw_pointer.hpp>
27
28 namespace boost {
29 namespace intrusive {
30 namespace detail {
31
32 // trivial header node holder
33 template < typename NodeTraits >
34 struct default_header_holder : public NodeTraits::node
35 {
36 typedef NodeTraits node_traits;
37 typedef typename node_traits::node node;
38 typedef typename node_traits::node_ptr node_ptr;
39 typedef typename node_traits::const_node_ptr const_node_ptr;
40
41 default_header_holder() : node() {}
42
43 BOOST_INTRUSIVE_FORCEINLINE const_node_ptr get_node() const
44 { return pointer_traits< const_node_ptr >::pointer_to(*static_cast< const node* >(this)); }
45
46 BOOST_INTRUSIVE_FORCEINLINE node_ptr get_node()
47 { return pointer_traits< node_ptr >::pointer_to(*static_cast< node* >(this)); }
48
49 // (unsafe) downcast used to implement container-from-iterator
50 BOOST_INTRUSIVE_FORCEINLINE static default_header_holder* get_holder(const node_ptr &p)
51 { return static_cast< default_header_holder* >(boost::intrusive::detail::to_raw_pointer(p)); }
52 };
53
54 // type function producing the header node holder
55 template < typename ValueTraits, typename HeaderHolder >
56 struct get_header_holder_type
57 {
58 typedef HeaderHolder type;
59 };
60 template < typename ValueTraits >
61 struct get_header_holder_type< ValueTraits, void >
62 {
63 typedef default_header_holder< typename ValueTraits::node_traits > type;
64 };
65
66 } //namespace detail
67 } //namespace intrusive
68 } //namespace boost
69
70 #endif //BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP