operator[] is not defined for list::iterator. Overload it in ilist::iterator
authorNick Lewycky <nicholas@mxc.ca>
Sat, 12 Jul 2008 07:00:52 +0000 (07:00 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sat, 12 Jul 2008 07:00:52 +0000 (07:00 +0000)
to prevent silly things from happening accidentally. PR2171

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53507 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/ilist.h

index 8d9bab5caaf0b048d2e3f1ab975b864fd81bbdd4..41253e030c5ffcba5ae1eaaa2a850b89a83ed966 100644 (file)
@@ -93,6 +93,10 @@ public:
   typedef typename super::reference reference;
 private:
   pointer NodePtr;
+
+  // operator[] is not defined. Compile error instead of having a runtime bug.
+  void operator[](unsigned) {}
+  void operator[](unsigned) const {}
 public:
 
   ilist_iterator(pointer NP) : NodePtr(NP) {}