How to cast const std::string& to integer?
<p>I have a variable like this:</p>

<pre><code>const std::string&amp; iterations = "30";
</code></pre>

<p>I want to use it to determine number of iterations for a "for" loop:</p>

<pre><code>for ( int i = 0; i &lt; iterations; i++ ) {
  // do something
}
</code></pre>

<p>How to do that? I know I can cast to string like this:</p>

<pre><code>iterations.c_str();
</code></pre>

<p>So I tried c_int() but it won't work:</p>

<pre><code>iterations.c_int();
</code></pre>
