1 | ///////////////////////////////////////////////////////////////////////////// |
---|---|
2 | // |
3 | // (C) Copyright Olaf Krzikalla 2004-2006. |
4 | // (C) Copyright Ion Gaztanaga 2006-2013 |
5 | // |
6 | // Distributed under the Boost Software License, Version 1.0. |
7 | // (See accompanying file LICENSE_1_0.txt or copy at |
8 | // http://www.boost.org/LICENSE_1_0.txt) |
9 | // |
10 | // See http://www.boost.org/libs/intrusive for documentation. |
11 | // |
12 | ///////////////////////////////////////////////////////////////////////////// |
13 | |
14 | #ifndef BOOST_INTRUSIVE_LIST_NODE_HPP |
15 | #define BOOST_INTRUSIVE_LIST_NODE_HPP |
16 | |
17 | #ifndef BOOST_CONFIG_HPP |
18 | # include <boost/config.hpp> |
19 | #endif |
20 | |
21 | #if defined(BOOST_HAS_PRAGMA_ONCE) |
22 | # pragma once |
23 | #endif |
24 | |
25 | #include <boost/intrusive/detail/workaround.hpp> |
26 | #include <boost/intrusive/pointer_rebind.hpp> |
27 | |
28 | namespace boost { |
29 | namespace intrusive { |
30 | |
31 | // list_node_traits can be used with circular_list_algorithms and supplies |
32 | // a list_node holding the pointers needed for a double-linked list |
33 | // it is used by list_derived_node and list_member_node |
34 | |
35 | template<class VoidPointer> |
36 | struct list_node |
37 | { |
38 | typedef typename pointer_rebind<VoidPointer, list_node>::type node_ptr; |
39 | node_ptr next_; |
40 | node_ptr prev_; |
41 | }; |
42 | |
43 | template<class VoidPointer> |
44 | struct list_node_traits |
45 | { |
46 | typedef list_node<VoidPointer> node; |
47 | typedef typename node::node_ptr node_ptr; |
48 | typedef typename pointer_rebind<VoidPointer, const node>::type const_node_ptr; |
49 | |
50 | BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_previous(const const_node_ptr & n) |
51 | { return n->prev_; } |
52 | |
53 | BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_previous(const node_ptr & n) |
54 | { return n->prev_; } |
55 | |
56 | BOOST_INTRUSIVE_FORCEINLINE static void set_previous(const node_ptr & n, const node_ptr & prev) |
57 | { n->prev_ = prev; } |
58 | |
59 | BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const const_node_ptr & n) |
60 | { return n->next_; } |
61 | |
62 | BOOST_INTRUSIVE_FORCEINLINE static node_ptr get_next(const node_ptr & n) |
63 | { return n->next_; } |
64 | |
65 | BOOST_INTRUSIVE_FORCEINLINE static void set_next(const node_ptr & n, const node_ptr & next) |
66 | { n->next_ = next; } |
67 | }; |
68 | |
69 | } //namespace intrusive |
70 | } //namespace boost |
71 | |
72 | #endif //BOOST_INTRUSIVE_LIST_NODE_HPP |
73 |