title: How can I enforce a vector to be immutable?
body: <p>I want to restrict vector to be unchanged. In following code when i use reference for each loop and increment each value, same is reflected in the vector. But I want to avoid.</p>
  <pre><code>#include &lt;vector&gt;
  #include &lt;iostream&gt;
  
  int main()
  {
      std::vector&lt;int&gt; port = {8, 0, 8, 0};    
      for (auto &amp;digit: port){
          digit++;
          std::cout &lt;&lt; digit &lt;&lt; std::endl;
      }
  }
  </code></pre>