Changeset 97d246d for src/Common
- Timestamp:
- Feb 14, 2017, 1:20:11 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- e58dfb9
- Parents:
- d3a804f5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/VectorMap.h
rd3a804f5 r97d246d 38 38 typedef const const_value_type* const_pointer; 39 39 40 class iterator : public std::iterator< std:: bidirectional_iterator_tag,40 class iterator : public std::iterator< std::random_access_iterator_tag, 41 41 value_type, 42 43 44 42 difference_type, 43 pointer, 44 reference > { 45 45 friend class VectorMap; 46 46 friend class const_iterator; … … 74 74 iterator operator-- (int) { iterator tmp = *this; --(*this); return tmp; } 75 75 76 iterator& operator+= (difference_type i) { 77 // SHENANIGANS: same reasons as operator++ 78 new(&data) value_type{ (data.first + i), *(&data.second + i) }; 79 return *this; 80 } 81 82 iterator operator+ (difference_type i) const { iterator tmp = *this; return tmp += i; } 83 84 iterator& operator-= (difference_type i) { 85 // SHENANIGANS: same reasons as operator++ 86 new(&data) value_type{ (data.first - i), *(&data.second - i) }; 87 return *this; 88 } 89 90 iterator operator- (difference_type i) const { iterator tmp = *this; return tmp -= i; } 91 92 difference_type operator- (const iterator& o) const { return data.first - o.data.first; } 93 94 value_type operator[] (difference_type i) const { 95 // SHENANIGANS: same reasons as operator++ 96 return value_type{ (data.first + i), *(&data.second + i) }; 97 } 98 76 99 bool operator== (const iterator& o) const { 77 100 return data.first == o.data.first && &data.second == &o.data.second; 78 101 } 102 79 103 bool operator!= (const iterator& that) const { return !(*this == that); } 104 105 bool operator< (const iterator& o) const { return data.first < o.data.first; } 106 107 bool operator> (const iterator& o) const { return data.first > o.data.first; } 108 109 bool operator<= (const iterator& o) const { return data.first <= o.data.first; } 110 111 bool operator>= (const iterator& o) const { return data.first >= o.data.first; } 80 112 }; 81 113 … … 118 150 const_iterator operator-- (int) { const_iterator tmp = *this; --(*this); return tmp; } 119 151 152 const_iterator& operator+= (difference_type i) { 153 // SHENANIGANS: same reasons as iterator::operator++ 154 new(&data) const_value_type{ (data.first + i), *(&data.second + i) }; 155 return *this; 156 } 157 158 const_iterator operator+ (difference_type i) const { 159 const_iterator tmp = *this; return tmp += i; 160 } 161 162 const_iterator& operator-= (difference_type i) { 163 // SHENANIGANS: same reasons as iterator::operator++ 164 new(&data) const_value_type{ (data.first - i), *(&data.second - i) }; 165 return *this; 166 } 167 168 const_iterator operator- (difference_type i) const { 169 const_iterator tmp = *this; return tmp -= i; 170 } 171 172 difference_type operator- (const const_iterator& o) const { 173 return data.first - o.data.first; 174 } 175 176 const_value_type operator[] (difference_type i) const { 177 // SHENANIGANS: same reasons as iterator::operator++ 178 return const_value_type{ (data.first + i), *(&data.second + i) }; 179 } 180 120 181 bool operator== (const const_iterator& o) const { 121 182 return data.first == o.data.first && &data.second == &o.data.second; 122 183 } 184 123 185 bool operator!= (const const_iterator& that) const { return !(*this == that); } 186 187 bool operator< (const const_iterator& o) const { return data.first < o.data.first; } 188 189 bool operator> (const const_iterator& o) const { return data.first > o.data.first; } 190 191 bool operator<= (const const_iterator& o) const { return data.first <= o.data.first; } 192 193 bool operator>= (const const_iterator& o) const { return data.first >= o.data.first; } 124 194 }; 125 195 … … 163 233 }; 164 234 235 template<typename T> 236 typename VectorMap<T>::iterator operator+ (typename VectorMap<T>::difference_type i, 237 const typename VectorMap<T>::iterator& it) { 238 return it + i; 239 } 240 241 template<typename T> 242 typename VectorMap<T>::const_iterator operator+ (typename VectorMap<T>::difference_type i, 243 const typename VectorMap<T>::const_iterator& it) { 244 return it + i; 245 } 246 165 247 #endif // _VECTORMAP_H 166 248
Note: See TracChangeset
for help on using the changeset viewer.