1
// This file has been generated by Py++.
4
// Header file proxy_iterator.hpp
6
// Copyright (c) 2003 Raoul M. Gough
8
// Use, modification and distribution is subject to the Boost Software
9
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy
10
// at http://www.boost.org/LICENSE_1_0.txt)
14
// 2003/10/ 8 rmg File creation
15
// 2008/12/08 Roman Change indexing suite layout
17
// $Id: proxy_iterator.hpp,v 1.1.2.8 2003/12/05 17:36:14 raoulgough Exp $
20
#ifndef BOOST_PYTHON_INDEXING_PROXY_ITERATOR_HPP
21
#define BOOST_PYTHON_INDEXING_PROXY_ITERATOR_HPP
24
#include <boost/config.hpp>
25
#include <boost/iterator.hpp>
26
#include <boost/detail/workaround.hpp>
28
namespace boost { namespace python { namespace indexing {
30
template <class ContainerProxy, typename ElementProxy, typename Traits,
31
typename Size, typename Iter>
33
: public boost::iterator<
34
std::random_access_iterator_tag,
36
typename Traits::difference_type,
38
ElementProxy // Already has reference semantics
41
#if !defined (BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
42
template<class C, class H, class G> friend class container_proxy;
45
typedef boost::iterator<
46
std::random_access_iterator_tag,
48
typename Traits::difference_type,
54
typedef ContainerProxy container_proxy_type;
56
typedef Iter raw_iterator;
57
typedef Traits raw_iterator_traits;
58
typedef Size size_type;
59
typedef typename base_type::value_type value_type;
60
typedef typename base_type::difference_type difference_type;
62
typedef value_type *pointer;
63
typedef value_type reference; // Already has reference semantics
65
proxy_iterator (container_proxy_type *p, size_type i)
70
proxy_iterator (container_proxy_type *p, raw_iterator iter)
71
: ptr (p), index (iter - p->raw_container().begin())
75
reference operator*() const { return ptr->at(index); }
76
pointer operator->() const { return &ptr->at(index); }
77
reference operator[](size_type s) { return ptr->at (index + s); }
79
proxy_iterator &operator++ () { ++index; return *this; }
80
proxy_iterator &operator+= (size_type s) { index += s; return *this; }
82
proxy_iterator &operator-- () { --index; return *this; }
84
proxy_iterator operator++ (int) {
85
proxy_iterator temp(*this);
90
proxy_iterator operator-- (int) {
91
proxy_iterator temp(*this);
96
proxy_iterator &operator-= (size_type s) { index -= s; return *this; }
98
proxy_iterator operator+ (size_type s) const {
99
return proxy_iterator(*this) += s;
102
proxy_iterator operator- (size_type s) const {
103
return proxy_iterator(*this) -= s;
106
difference_type operator- (proxy_iterator i) const {
107
return index - i.index;
110
bool operator== (proxy_iterator const &other) const {
111
return (ptr == other.ptr) && (index == other.index);
114
bool operator!= (proxy_iterator const &other) const {
115
return !(*this == other);
118
bool operator< (proxy_iterator const &other) const {
119
return index < other.index;
122
bool operator<= (proxy_iterator const &other) const {
123
return index <= other.index;
126
bool operator> (proxy_iterator const &other) const {
127
return index > other.index;
130
bool operator>= (proxy_iterator const &other) const {
131
return index >= other.index;
134
void iter_swap (proxy_iterator const &other) const {
135
ptr->swap_elements (index, other.index);
139
// Extensions to the normal iterator interface
140
// void replace (value_type const ©) { ptr->replace (index, copy); }
142
#if defined (BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
143
// Can't declare container_proxy as friend, so make data public
148
container_proxy_type *ptr;
153
#if !BOOST_WORKAROUND (BOOST_MSVC, == 1300)
154
// MSVC7.0 can't decide between this and the unspecialized version
156
template <class C, typename E, typename T, typename S, typename I>
158
boost::python::indexing::proxy_iterator<C, E, T, S, I> const &first,
159
boost::python::indexing::proxy_iterator<C, E, T, S, I> const &second)
161
first.iter_swap (second);
166
#endif // BOOST_PYTHON_INDEXING_PROXY_ITERATOR_HPP