]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/multi_index/include/boost/multi_index/detail/hash_index_iterator.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / multi_index / include / boost / multi_index / detail / hash_index_iterator.hpp
CommitLineData
7c673cae
FG
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_HASH_INDEX_ITERATOR_HPP
10#define BOOST_MULTI_INDEX_DETAIL_HASH_INDEX_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#include <boost/serialization/version.hpp>
23#endif
24
25namespace boost{
26
27namespace multi_index{
28
29namespace detail{
30
31/* Iterator class for hashed indices.
32 */
33
34struct hashed_index_global_iterator_tag{};
35struct hashed_index_local_iterator_tag{};
36
37template<typename Node,typename BucketArray,typename Category>
38class hashed_index_iterator:
39 public forward_iterator_helper<
40 hashed_index_iterator<Node,BucketArray,Category>,
41 typename Node::value_type,
42 std::ptrdiff_t,
43 const typename Node::value_type*,
44 const typename Node::value_type&>
45{
46public:
47 /* coverity[uninit_ctor]: suppress warning */
48 hashed_index_iterator(){}
49 hashed_index_iterator(Node* node_):node(node_){}
50
51 const typename Node::value_type& operator*()const
52 {
53 return node->value();
54 }
55
56 hashed_index_iterator& operator++()
57 {
58 this->increment(Category());
59 return *this;
60 }
61
62#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
63 /* Serialization. As for why the following is public,
64 * see explanation in safe_mode_iterator notes in safe_mode.hpp.
65 */
66
67 BOOST_SERIALIZATION_SPLIT_MEMBER()
68
69 typedef typename Node::base_type node_base_type;
70
71 template<class Archive>
72 void save(Archive& ar,const unsigned int)const
73 {
74 node_base_type* bnode=node;
75 ar<<serialization::make_nvp("pointer",bnode);
76 }
77
78 template<class Archive>
79 void load(Archive& ar,const unsigned int version)
80 {
81 load(ar,version,Category());
82 }
83
84 template<class Archive>
85 void load(
86 Archive& ar,const unsigned int version,hashed_index_global_iterator_tag)
87 {
88 node_base_type* bnode;
89 ar>>serialization::make_nvp("pointer",bnode);
90 node=static_cast<Node*>(bnode);
91 if(version<1){
92 BucketArray* throw_away; /* consume unused ptr */
93 ar>>serialization::make_nvp("pointer",throw_away);
94 }
95 }
96
97 template<class Archive>
98 void load(
99 Archive& ar,const unsigned int version,hashed_index_local_iterator_tag)
100 {
101 node_base_type* bnode;
102 ar>>serialization::make_nvp("pointer",bnode);
103 node=static_cast<Node*>(bnode);
104 if(version<1){
105 BucketArray* buckets;
106 ar>>serialization::make_nvp("pointer",buckets);
107 if(buckets&&node&&node->impl()==buckets->end()->prior()){
108 /* end local_iterators used to point to end node, now they are null */
109 node=0;
110 }
111 }
112 }
113#endif
114
115 /* get_node is not to be used by the user */
116
117 typedef Node node_type;
118
119 Node* get_node()const{return node;}
120
121private:
122
123 void increment(hashed_index_global_iterator_tag)
124 {
125 Node::increment(node);
126 }
127
128 void increment(hashed_index_local_iterator_tag)
129 {
130 Node::increment_local(node);
131 }
132
133 Node* node;
134};
135
136template<typename Node,typename BucketArray,typename Category>
137bool operator==(
138 const hashed_index_iterator<Node,BucketArray,Category>& x,
139 const hashed_index_iterator<Node,BucketArray,Category>& y)
140{
141 return x.get_node()==y.get_node();
142}
143
144} /* namespace multi_index::detail */
145
146} /* namespace multi_index */
147
148#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
149/* class version = 1 : hashed_index_iterator does no longer serialize a bucket
150 * array pointer.
151 */
152
153namespace serialization {
154template<typename Node,typename BucketArray,typename Category>
155struct version<
156 boost::multi_index::detail::hashed_index_iterator<Node,BucketArray,Category>
157>
158{
159 BOOST_STATIC_CONSTANT(int,value=1);
160};
161} /* namespace serialization */
162#endif
163
164} /* namespace boost */
165
166#endif