1 /* Copyright 2003-2014 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
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 /* coverity[uninit_ctor]: suppress warning */
45 bidir_node_iterator(){}
46 explicit bidir_node_iterator(Node* node_):node(node_){}
48 const typename Node::value_type& operator*()const
53 bidir_node_iterator& operator++()
55 Node::increment(node);
59 bidir_node_iterator& operator--()
61 Node::decrement(node);
65 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
66 /* Serialization. As for why the following is public,
67 * see explanation in safe_mode_iterator notes in safe_mode.hpp.
70 BOOST_SERIALIZATION_SPLIT_MEMBER()
72 typedef typename Node::base_type node_base_type;
74 template<class Archive>
75 void save(Archive& ar,const unsigned int)const
77 node_base_type* bnode=node;
78 ar<<serialization::make_nvp("pointer",bnode);
81 template<class Archive>
82 void load(Archive& ar,const unsigned int)
84 node_base_type* bnode;
85 ar>>serialization::make_nvp("pointer",bnode);
86 node=static_cast<Node*>(bnode);
90 /* get_node is not to be used by the user */
92 typedef Node node_type;
94 Node* get_node()const{return node;}
100 template<typename Node>
102 const bidir_node_iterator<Node>& x,
103 const bidir_node_iterator<Node>& y)
105 return x.get_node()==y.get_node();
108 } /* namespace multi_index::detail */
110 } /* namespace multi_index */
112 } /* namespace boost */