1 /* Copyright 2003-2008 Joaquin M Lopez Munoz.
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * See http://www.boost.org/libs/multi_index for library home page.
9 #ifndef BOOST_MULTI_INDEX_DETAIL_BIDIR_NODE_ITERATOR_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_BIDIR_NODE_ITERATOR_HPP
12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
17 #include <boost/operators.hpp>
19 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
20 #include <boost/serialization/nvp.hpp>
21 #include <boost/serialization/split_member.hpp>
26 namespace multi_index
{
30 /* Iterator class for node-based indices with bidirectional
31 * iterators (ordered and sequenced indices.)
34 template<typename Node
>
35 class bidir_node_iterator
:
36 public bidirectional_iterator_helper
<
37 bidir_node_iterator
<Node
>,
38 typename
Node::value_type
,
40 const typename
Node::value_type
*,
41 const typename
Node::value_type
&>
44 bidir_node_iterator(){}
45 explicit bidir_node_iterator(Node
* node_
):node(node_
){}
47 const typename
Node::value_type
& operator*()const
52 bidir_node_iterator
& operator++()
54 Node::increment(node
);
58 bidir_node_iterator
& operator--()
60 Node::decrement(node
);
64 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
65 /* Serialization. As for why the following is public,
66 * see explanation in safe_mode_iterator notes in safe_mode.hpp.
69 BOOST_SERIALIZATION_SPLIT_MEMBER()
71 typedef typename
Node::base_type node_base_type
;
73 template<class Archive
>
74 void save(Archive
& ar
,const unsigned int)const
76 node_base_type
* bnode
=node
;
77 ar
<<serialization::make_nvp("pointer",bnode
);
80 template<class Archive
>
81 void load(Archive
& ar
,const unsigned int)
83 node_base_type
* bnode
;
84 ar
>>serialization::make_nvp("pointer",bnode
);
85 node
=static_cast<Node
*>(bnode
);
89 /* get_node is not to be used by the user */
91 typedef Node node_type
;
93 Node
* get_node()const{return node
;}
99 template<typename Node
>
101 const bidir_node_iterator
<Node
>& x
,
102 const bidir_node_iterator
<Node
>& y
)
104 return x
.get_node()==y
.get_node();
107 } /* namespace multi_index::detail */
109 } /* namespace multi_index */
111 } /* namespace boost */