]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/multi_index/detail/bidir_node_iterator.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / multi_index / detail / bidir_node_iterator.hpp
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)
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)
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>
35 class bidir_node_iterator:
36 public bidirectional_iterator_helper<
37 bidir_node_iterator<Node>,
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 /* coverity[uninit_ctor]: suppress warning */
45 bidir_node_iterator(){}
46 explicit bidir_node_iterator(Node* node_):node(node_){}
47
48 const typename Node::value_type& operator*()const
49 {
50 return node->value();
51 }
52
53 bidir_node_iterator& operator++()
54 {
55 Node::increment(node);
56 return *this;
57 }
58
59 bidir_node_iterator& operator--()
60 {
61 Node::decrement(node);
62 return *this;
63 }
64
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.
68 */
69
70 BOOST_SERIALIZATION_SPLIT_MEMBER()
71
72 typedef typename Node::base_type node_base_type;
73
74 template<class Archive>
75 void save(Archive& ar,const unsigned int)const
76 {
77 node_base_type* bnode=node;
78 ar<<serialization::make_nvp("pointer",bnode);
79 }
80
81 template<class Archive>
82 void load(Archive& ar,const unsigned int)
83 {
84 node_base_type* bnode;
85 ar>>serialization::make_nvp("pointer",bnode);
86 node=static_cast<Node*>(bnode);
87 }
88 #endif
89
90 /* get_node is not to be used by the user */
91
92 typedef Node node_type;
93
94 Node* get_node()const{return node;}
95
96 private:
97 Node* node;
98 };
99
100 template<typename Node>
101 bool operator==(
102 const bidir_node_iterator<Node>& x,
103 const bidir_node_iterator<Node>& y)
104 {
105 return x.get_node()==y.get_node();
106 }
107
108 } /* namespace multi_index::detail */
109
110 } /* namespace multi_index */
111
112 } /* namespace boost */
113
114 #endif