[PATCH] Use 'auto const&' for iterators whose deref operator returns a const var
Edwin Vane
edwin.vane at intel.com
Thu May 9 09:51:31 PDT 2013
Almost there.
================
Comment at: test/cpp11-migrate/LoopConvert/single-iterator.cpp:119
@@ +118,3 @@
+// initializer type have the same type.
+void same_type() {
+ S s;
----------------
How are these same_type() tests different from any of the other tests which already ensure (thanks your changes) that the init var has the same type as the initializer? I don't think these tests are necessary in that light.
================
Comment at: test/cpp11-migrate/LoopConvert/single-iterator.cpp:141
@@ +140,3 @@
+ S s;
+ for (S::const_iterator it = s.begin(); it != s.end(); ++it) {
+ printf("s has value %d\n", (*it).x);
----------------
I'd just add a note that s.begin() returns a type 'iterator' which is just a non-const pointer.
================
Comment at: test/cpp11-migrate/LoopConvert/single-iterator.cpp:155
@@ +154,3 @@
+ dependent<int> v;
+ for (dependent<int>::const_iterator it = v.begin(); it != v.end(); ++it) {
+ printf("Fibonacci number is %d\n", *it);
----------------
Similarly, I'd say that v.begin() returns a user-defined type 'iterator' which, since it's different from const_iterator, disqualifies this loop from transformation.
http://llvm-reviews.chandlerc.com/D759
More information about the cfe-commits
mailing list