Add Boost.Test karmic valgrind suppressions
[senf.git] / boost / multi_index / detail / bidir_node_iterator.hpp
1 /* Copyright 2003-2007 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)
5  *
6  * See http://www.boost.org/libs/multi_index for library home page.
7  */
8
9 #ifndef BOOST_MULTI_INDEX_DETAIL_BIDIR_NODE_ITERATOR_HPP
10 #define BOOST_MULTI_INDEX_DETAIL_BIDIR_NODE_ITERATOR_HPP
11
12 #if defined(_MSC_VER)&&(_MSC_VER>=1200)
13 #pragma once
14 #endif
15
16 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
17 #include <boost/operators.hpp>
18
19 #if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
20 #include <boost/serialization/nvp.hpp>
21 #include <boost/serialization/split_member.hpp>
22 #endif
23
24 namespace boost{
25
26 namespace multi_index{
27
28 namespace detail{
29
30 /* Iterator class for node-based indices with bidirectional
31  * iterators (ordered and sequenced indices.)
32  */
33
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&>
42 {
43 public:
44   bidir_node_iterator(){}
45   explicit bidir_node_iterator(Node* node_):node(node_){}
46
47   const typename Node::value_type& operator*()const
48   {
49     return node->value();
50   }
51
52   bidir_node_iterator& operator++()
53   {
54     Node::increment(node);
55     return *this;
56   }
57
58   bidir_node_iterator& operator--()
59   {
60     Node::decrement(node);
61     return *this;
62   }
63
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.
67    */
68
69   BOOST_SERIALIZATION_SPLIT_MEMBER()
70
71   typedef typename Node::base_type node_base_type;
72
73   template<class Archive>
74   void save(Archive& ar,const unsigned int)const
75   {
76     node_base_type* bnode=node;
77     ar<<serialization::make_nvp("pointer",bnode);
78   }
79
80   template<class Archive>
81   void load(Archive& ar,const unsigned int)
82   {
83     node_base_type* bnode;
84     ar>>serialization::make_nvp("pointer",bnode);
85     node=static_cast<Node*>(bnode);
86   }
87 #endif
88
89   /* get_node is not to be used by the user */
90
91   typedef Node node_type;
92
93   Node* get_node()const{return node;}
94
95 private:
96   Node* node;
97 };
98
99 template<typename Node,typename Derived>
100 bool operator==(
101   const bidir_node_iterator<Node,Derived>& x,
102   const bidir_node_iterator<Node,Derived>& y)
103 {
104   return x.get_node()==y.get_node();
105 }
106
107 } /* namespace multi_index::detail */
108
109 } /* namespace multi_index */
110
111 } /* namespace boost */
112
113 #endif