]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/iterator/example/node_iterator2.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / iterator / example / node_iterator2.hpp
CommitLineData
7c673cae
FG
1// Copyright David Abrahams 2004. Use, modification and distribution is
2// subject to the Boost Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4#ifndef NODE_ITERATOR2_DWA2004110_HPP
5# define NODE_ITERATOR2_DWA2004110_HPP
6
7# include "node.hpp"
8# include <boost/iterator/iterator_facade.hpp>
9
10# ifndef BOOST_NO_SFINAE
11# include <boost/type_traits/is_convertible.hpp>
12# include <boost/utility/enable_if.hpp>
13# endif
14
15template <class Value>
16class node_iter
17 : public boost::iterator_facade<
18 node_iter<Value>
19 , Value
20 , boost::forward_traversal_tag
21 >
22{
23 private:
24 struct enabler {}; // a private type avoids misuse
25
26 public:
27 node_iter()
28 : m_node(0) {}
29
30 explicit node_iter(Value* p)
31 : m_node(p) {}
32
33 template <class OtherValue>
34 node_iter(
35 node_iter<OtherValue> const& other
36# ifndef BOOST_NO_SFINAE
37 , typename boost::enable_if<
38 boost::is_convertible<OtherValue*,Value*>
39 , enabler
40 >::type = enabler()
1e59de90 41# endif
7c673cae
FG
42 )
43 : m_node(other.m_node) {}
44
45
46# if !BOOST_WORKAROUND(__GNUC__, == 2)
1e59de90 47 private: // GCC2 can't grant friendship to template member functions
7c673cae 48 friend class boost::iterator_core_access;
1e59de90 49# endif
7c673cae
FG
50
51 template <class OtherValue>
52 bool equal(node_iter<OtherValue> const& other) const
53 {
54 return this->m_node == other.m_node;
55 }
56
57 void increment() { m_node = m_node->next(); }
58
59 Value& dereference() const { return *m_node; }
60
61# ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
62 public:
63# else
64 private:
65 template <class> friend class node_iter;
1e59de90 66# endif
7c673cae
FG
67 Value* m_node;
68};
69
70typedef node_iter<node_base> node_iterator;
71typedef node_iter<node_base const> node_const_iterator;
72
73#endif // NODE_ITERATOR2_DWA2004110_HPP