Chris@102
|
1 /////////////////////////////////////////////////////////////////////////////
|
Chris@102
|
2 //
|
Chris@102
|
3 // (C) Copyright Ion Gaztanaga 2014-2014
|
Chris@102
|
4 //
|
Chris@102
|
5 // Distributed under the Boost Software License, Version 1.0.
|
Chris@102
|
6 // (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@102
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
8 //
|
Chris@102
|
9 // See http://www.boost.org/libs/intrusive for documentation.
|
Chris@102
|
10 //
|
Chris@102
|
11 /////////////////////////////////////////////////////////////////////////////
|
Chris@102
|
12
|
Chris@102
|
13 #ifndef BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP
|
Chris@102
|
14 #define BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP
|
Chris@102
|
15
|
Chris@102
|
16 #ifndef BOOST_CONFIG_HPP
|
Chris@102
|
17 # include <boost/config.hpp>
|
Chris@102
|
18 #endif
|
Chris@102
|
19
|
Chris@102
|
20 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@102
|
21 # pragma once
|
Chris@102
|
22 #endif
|
Chris@102
|
23
|
Chris@102
|
24 #include <boost/intrusive/pointer_traits.hpp>
|
Chris@102
|
25 #include <boost/intrusive/detail/to_raw_pointer.hpp>
|
Chris@102
|
26
|
Chris@102
|
27 namespace boost {
|
Chris@102
|
28 namespace intrusive {
|
Chris@102
|
29 namespace detail {
|
Chris@102
|
30
|
Chris@102
|
31 // trivial header node holder
|
Chris@102
|
32 template < typename NodeTraits >
|
Chris@102
|
33 struct default_header_holder : public NodeTraits::node
|
Chris@102
|
34 {
|
Chris@102
|
35 typedef NodeTraits node_traits;
|
Chris@102
|
36 typedef typename node_traits::node node;
|
Chris@102
|
37 typedef typename node_traits::node_ptr node_ptr;
|
Chris@102
|
38 typedef typename node_traits::const_node_ptr const_node_ptr;
|
Chris@102
|
39
|
Chris@102
|
40 default_header_holder() : node() {}
|
Chris@102
|
41
|
Chris@102
|
42 const_node_ptr get_node() const
|
Chris@102
|
43 { return pointer_traits< const_node_ptr >::pointer_to(*static_cast< const node* >(this)); }
|
Chris@102
|
44
|
Chris@102
|
45 node_ptr get_node()
|
Chris@102
|
46 { return pointer_traits< node_ptr >::pointer_to(*static_cast< node* >(this)); }
|
Chris@102
|
47
|
Chris@102
|
48 // (unsafe) downcast used to implement container-from-iterator
|
Chris@102
|
49 static default_header_holder* get_holder(const node_ptr &p)
|
Chris@102
|
50 { return static_cast< default_header_holder* >(boost::intrusive::detail::to_raw_pointer(p)); }
|
Chris@102
|
51 };
|
Chris@102
|
52
|
Chris@102
|
53 // type function producing the header node holder
|
Chris@102
|
54 template < typename Value_Traits, typename HeaderHolder >
|
Chris@102
|
55 struct get_header_holder_type
|
Chris@102
|
56 {
|
Chris@102
|
57 typedef HeaderHolder type;
|
Chris@102
|
58 };
|
Chris@102
|
59 template < typename Value_Traits >
|
Chris@102
|
60 struct get_header_holder_type< Value_Traits, void >
|
Chris@102
|
61 {
|
Chris@102
|
62 typedef default_header_holder< typename Value_Traits::node_traits > type;
|
Chris@102
|
63 };
|
Chris@102
|
64
|
Chris@102
|
65 } //namespace detail
|
Chris@102
|
66 } //namespace intrusive
|
Chris@102
|
67 } //namespace boost
|
Chris@102
|
68
|
Chris@102
|
69 #endif //BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP
|