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 |
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/pointer_traits.hpp> |
25 | #include <boost/intrusive/detail/to_raw_pointer.hpp> |
26 | |
27 | namespace boost { |
28 | namespace intrusive { |
29 | namespace detail { |
30 | |
31 | // trivial header node holder |
32 | template < typename NodeTraits > |
33 | struct : public NodeTraits::node |
34 | { |
35 | typedef NodeTraits ; |
36 | typedef typename node_traits::node ; |
37 | typedef typename node_traits::node_ptr ; |
38 | typedef typename node_traits::const_node_ptr ; |
39 | |
40 | () : node() {} |
41 | |
42 | const_node_ptr () const |
43 | { return pointer_traits< const_node_ptr >::pointer_to(*static_cast< const node* >(this)); } |
44 | |
45 | node_ptr () |
46 | { return pointer_traits< node_ptr >::pointer_to(*static_cast< node* >(this)); } |
47 | |
48 | // (unsafe) downcast used to implement container-from-iterator |
49 | static default_header_holder* (const node_ptr &p) |
50 | { return static_cast< default_header_holder* >(boost::intrusive::detail::to_raw_pointer(p)); } |
51 | }; |
52 | |
53 | // type function producing the header node holder |
54 | template < typename Value_Traits, typename HeaderHolder > |
55 | struct |
56 | { |
57 | typedef HeaderHolder ; |
58 | }; |
59 | template < typename Value_Traits > |
60 | struct < Value_Traits, void > |
61 | { |
62 | typedef default_header_holder< typename Value_Traits::node_traits > ; |
63 | }; |
64 | |
65 | } //namespace detail |
66 | } //namespace intrusive |
67 | } //namespace boost |
68 | |
69 | #endif //BOOST_INTRUSIVE_DETAIL_DEFAULT_HEADER_HOLDER_HPP |
70 | |