[STLExtras] Make const the * operator for mapped_iterator.
authorAlina Sbirlea <asbirlea@google.com>
Tue, 14 Apr 2020 01:51:20 +0000 (18:51 -0700)
committerAlina Sbirlea <asbirlea@google.com>
Tue, 14 Apr 2020 18:04:20 +0000 (11:04 -0700)
Summary:
The current non-const * operator shadows the const operator in
iterator_adaptor_base.

Reviewers: mehdi_amini, rriddle!, dblaikie, timshen

Subscribers: dexonsmith, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, grosul1, frgossen, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78073

llvm/include/llvm/ADT/STLExtras.h
mlir/include/mlir/IR/Attributes.h

index 529219e..215bc5a 100644 (file)
@@ -214,7 +214,7 @@ public:
 
   ItTy getCurrent() { return this->I; }
 
-  FuncReturnTy operator*() { return F(*this->I); }
+  FuncReturnTy operator*() const { return F(*this->I); }
 
 private:
   FuncTy F;
index e71359e..51b6edf 100644 (file)
@@ -228,7 +228,7 @@ private:
     explicit attr_value_iterator(ArrayAttr::iterator it)
         : llvm::mapped_iterator<ArrayAttr::iterator, AttrTy (*)(Attribute)>(
               it, [](Attribute attr) { return attr.cast<AttrTy>(); }) {}
-    AttrTy operator*() { return (*this->I).template cast<AttrTy>(); }
+    AttrTy operator*() const { return (*this->I).template cast<AttrTy>(); }
   };
 
 public: