title: Error: no match for operator[]. While comparing int to int in list<int>,
body: <p>I'm trying to compare the integers in a list to integers but for some reason I get the error: no match for operator[], and I don't understand why. I have simplified what I have been trying to do below, but it's still the same core issue I have. Here is the code:</p>
  
  <pre><code>int main(){
      list&lt;int&gt; myBinaryList;
      int count;
      for (count = 0; count &lt; 4, count++){
      myBinaryList.push_back(1)
      }
      //now I should have a list that looks like: (1, 1, 1, 1)
  
      for (auto const&amp; i:myBinaryList){
          if (myBinaryList[i]==1){ //it's on this row that I will get the error
          myBinaryList[i]=0;
          }
      }
  
     return 0;
     }
  </code></pre>
  
  <p>Why do I get this error and how do I compare integers to integers in a list?</p>