Improve vacpp support.
[boost.git] / boost / boost / multi_index / detail / bidir_node_iterator.hpp
blobfb4e87e4a0b7a3a536444a5e181445ec65ce7e2a
1 /* Copyright 2003-2006 Joaquín M López Muñoz.
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.
7 */
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)
13 #pragma once
14 #endif
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>
22 #endif
24 namespace boost{
26 namespace multi_index{
28 namespace detail{
30 /* Iterator class for node-based indices with bidirectional
31 * iterators (ordered and sequenced indices.)
34 template<typename Node,typename Derived=mpl::na>
35 class bidir_node_iterator:
36 public bidirectional_iterator_helper<
37 bidir_node_iterator<Node,Derived>,
38 typename Node::value_type,
39 std::ptrdiff_t,
40 const typename Node::value_type*,
41 const typename Node::value_type&>
43 public:
44 bidir_node_iterator(){}
45 explicit bidir_node_iterator(Node* node_):node(node_){}
47 const typename Node::value_type& operator*()const
49 return node->value();
52 friend bool operator==(
53 const bidir_node_iterator& x,const bidir_node_iterator& y)
55 return x.node==y.node;
58 bidir_node_iterator& operator++()
60 Node::increment(node);
61 return *this;
64 bidir_node_iterator& operator--()
66 Node::decrement(node);
67 return *this;
70 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
71 /* Serialization. As for why the following is public,
72 * see explanation in safe_mode_iterator notes in safe_mode.hpp.
75 BOOST_SERIALIZATION_SPLIT_MEMBER()
77 typedef typename Node::base_type node_base_type;
79 template<class Archive>
80 void save(Archive& ar,const unsigned int)const
82 node_base_type* bnode=node;
83 ar<<serialization::make_nvp("pointer",bnode);
86 template<class Archive>
87 void load(Archive& ar,const unsigned int)
89 node_base_type* bnode;
90 ar>>serialization::make_nvp("pointer",bnode);
91 node=static_cast<Node*>(bnode);
93 #endif
95 /* get_node is not to be used by the user */
97 typedef Node node_type;
99 Node* get_node()const{return node;}
101 private:
102 Node* node;
105 } /* namespace multi_index::detail */
107 } /* namespace multi_index */
109 } /* namespace boost */
111 #endif