43#ifndef LASS_GUARDIAN_OF_INCLUSION_STDE_TRANSFORM_ITERATOR_H
44#define LASS_GUARDIAN_OF_INCLUSION_STDE_TRANSFORM_ITERATOR_H
87class access_iterator_t
90 typedef Iterator iterator_type;
91 typedef Accessor accessor_type;
92 typedef typename std::iterator_traits<Iterator>::iterator_category iterator_category;
93 typedef typename Accessor::value_type value_type;
94 typedef typename std::iterator_traits<Iterator>::difference_type difference_type;
95 typedef typename Accessor::pointer pointer;
96 typedef typename Accessor::reference reference;
98 access_iterator_t(iterator_type i = iterator_type(), accessor_type a = accessor_type()): current_(i), accessor_(a) {}
100 iterator_type base()
const {
return current_; }
101 pointer operator->()
const {
return &accessor_(current_); }
102 reference operator*()
const {
return accessor_(current_); }
104 access_iterator_t& operator++() { ++current_;
return *
this; }
105 access_iterator_t operator++(
int) {
return access_iterator_t(current_++, accessor_); }
106 access_iterator_t& operator--() { --current_;
return *
this; }
107 access_iterator_t operator--(
int) {
return access_iterator_t(current_--, accessor_); }
109 access_iterator_t& operator+=(difference_type n) { current_ += n;
return *
this; }
110 access_iterator_t operator+(difference_type n) {
return access_iterator_t(current_ + n, accessor_); }
111 access_iterator_t& operator-=(difference_type n) { current_ -= n;
return *
this; }
112 access_iterator_t operator-(difference_type n) {
return access_iterator_t(current_ - n, accessor_); }
114 reference operator[](difference_type n)
const {
return accessor_(current_[n]); }
117 iterator_type current_;
118 accessor_type accessor_;
122template <
typename I,
typename V>
125template <
typename I,
typename V>
126bool operator==(
const access_iterator_t<I, V>& a,
const access_iterator_t<I, V>& b) {
return a.base() == b.base(); }
128template <
typename I,
typename V>
129bool operator!=(
const access_iterator_t<I, V>& a,
const access_iterator_t<I, V>& b) {
return a.base() != b.base(); }
131template <
typename I,
typename V>
134template <
typename I,
typename V>
137template <
typename I,
typename V>
140template <
typename I,
typename V>
145template <
typename BaseReference,
typename Value>
struct accessor_helper_t;
147template <
typename Base,
typename Value>
148struct accessor_helper_t<Base&, Value>
150 typedef Base& argument_type;
151 typedef Value& result_type;
153 typedef Value& reference;
156 ~accessor_helper_t() {}
159template <
typename Base,
typename Value>
160struct accessor_helper_t<const Base&, Value>
162 typedef const Base& argument_type;
163 typedef const Value& result_type;
165 typedef const Value& reference;
168 ~accessor_helper_t() {}
173template <
typename It,
typename First>
174struct first_accessor_t: accessor_helper_t<typename std::iterator_traits<It>::reference, First>
176 typedef typename accessor_helper_t<typename std::iterator_traits<It>::reference, First>::reference reference;
177 reference operator()(It i)
const {
return i->first; }
182template <
typename It>
191template <
typename It,
typename Second>
192struct second_accessor_t: accessor_helper_t<typename std::iterator_traits<It>::reference, Second>
194 typedef typename accessor_helper_t<typename std::iterator_traits<It>::reference, Second>::reference reference;
195 reference operator()(It i)
const {
return i->second; }
200template <
typename It>
208template <
typename It,
typename Value,
typename Base>
209struct member_accessor_t: accessor_helper_t<Base&, Value>
211 typedef Value Base::*mem_ptr_type;
212 typedef typename accessor_helper_t<Base&, Value>::reference reference;
213 member_accessor_t(mem_ptr_type mem_ptr = mem_ptr_type()): mem_ptr_(mem_ptr) {}
214 reference operator()(It i)
const {
return (*i).*mem_ptr_; }
216 mem_ptr_type mem_ptr_;
219template <
typename It,
typename Value,
typename Base>
221member_iterator(It i, Value Base::*mem_ptr)
226template <
typename It,
typename Value,
typename Base>
228const_member_iterator(It i, Value Base::*mem_ptr)
iterator adaptor to access members.
lass extensions to the standard library
Library for Assembled Shared Sources.