Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: mojo/public/cpp/bindings/array.h

Issue 1372233002: Fix |Array| and iterator_util.h's Iterator operator->() behavior (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/lib/iterator_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_
7 7
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 Iterator operator--(int) { 190 Iterator operator--(int) {
191 Iterator original = *this; 191 Iterator original = *this;
192 --pos_; 192 --pos_;
193 return original; 193 return original;
194 } 194 }
195 bool operator==(const Iterator& o) const { 195 bool operator==(const Iterator& o) const {
196 return o.arr_ == arr_ && o.pos_ == pos_; 196 return o.arr_ == arr_ && o.pos_ == pos_;
197 } 197 }
198 bool operator!=(const Iterator& o) const { return !(*this == o); } 198 bool operator!=(const Iterator& o) const { return !(*this == o); }
199 RefType operator*() const { return arr_->at(pos_); } 199 RefType operator*() const { return arr_->at(pos_); }
200 RefType operator->() const { return operator*(); } 200 T* operator->() const { return &arr_->at(pos_); }
201 201
202 // The following satisfy RandomAccessIterator: 202 // The following satisfy RandomAccessIterator:
203 Iterator& operator+=(difference_type dist) { 203 Iterator& operator+=(difference_type dist) {
204 pos_ += dist; 204 pos_ += dist;
205 return *this; 205 return *this;
206 } 206 }
207 Iterator& operator-=(difference_type dist) { 207 Iterator& operator-=(difference_type dist) {
208 pos_ -= dist; 208 pos_ -= dist;
209 return *this; 209 return *this;
210 } 210 }
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 for (size_t i = 0; i < input.size(); ++i) 303 for (size_t i = 0; i < input.size(); ++i)
304 result.insert(TypeConverter<E, T>::Convert(input[i])); 304 result.insert(TypeConverter<E, T>::Convert(input[i]));
305 } 305 }
306 return result; 306 return result;
307 } 307 }
308 }; 308 };
309 309
310 } // namespace mojo 310 } // namespace mojo
311 311
312 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ 312 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/lib/iterator_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698