title: Infinite for in C++
body: <p>I want to loop over a <code>std::vector</code> over and over again until I break from the loop. Is this the best way?</p>
  
  <pre><code>int main() {
  std::string str;
  std::ifstream infile;
  std::vector&lt;int&gt; vec;
  std::set&lt;int&gt; sums;
  int sum = 0;
  sums.insert(sum);
  infile.open("Text.txt");
  while (!infile.eof()) {
      getline(infile, str);
      vec.push_back(std::stoi(str));
  }
  infile.close();
  
  while (true) {
      for (int i : vec) {
          sum += i;
          if (sums.count(sum)) {
              std::cout &lt;&lt; sum;           
              return 0;
          }
          sums.insert(sum);
      }
  }
  </code></pre>
  
  <p>}</p>