Defining variables with dependent names
<p>I want to define variables whose names depend on the values of other variables, such as</p>

<pre><code>for (int i = 0; i &lt; 5; i++) {
    int v_i = 2 * i
}

std::cout &lt;&lt; v_3; // output: 6
</code></pre>

<p>or</p>

<pre><code>int m;
std::cin &gt;&gt; m; // m = 42

int v_m = 10;

std::cout &lt;&lt; v_42; // output: 10
</code></pre>

<p>Of course, these examples do  not work but instead just create variables with the names <code>v_i</code> or <code>v_m</code>, treating i and m as characters.</p>

<p>How could I accomplish this?</p>