Make a variable unusable/unaccessible in scope halfway <p>Let's say I have this code:</p> <pre><code>for (int i = 0; i &lt; x.size(); i++) { auto &amp;in = input[i]; auto &amp;func = functions[i]; auto &amp;out = output[i]; // pseudo-code from here: unaccessiable(i); i = func(in); // error, i is not declared out = func(i); // error, i is not declared // useful when you mistake in/out for i } </code></pre> <p>I need to achieve effect that a variable is not accessible or usable after a certain line in the code. (in this code, after the <code>unaccessiable(i)</code>) Specifically I want to disable the iterator of a for's loop.</p> <p>NOTE: This is only for code correctness, and nothing beyond that. So lambdas (non-compile-time solutions) are just performance hindering.</p>