Casting in a compound assignment operator?
<p>I have code that, reduced to its essence, comes down to:</p>

<pre><code>int x = 5;
x *= 0.5;
</code></pre>

<p>Compiling this with Visual Studio, I get a warning C4244 about possible loss of data - of course, because (simplified) the multiplication of an int by a double results in a double which is then cast to an int, losing the non-integer part.</p>

<p>My question is, is there C++ syntax to indicate that this the intended behavior, so as to silence the warning (I know about pragma push/pop to disable the warning, I think it's clearer to indicate that this is actually intended behavior, and that I'm not just suppressing warnings).</p>

<p>The long-form would be to cast explicitly after the multiplication like so:</p>

<pre><code>x = (int)(x * 0.5);
</code></pre>

<p>but the compound-operator notation is easier to read.</p>

<p>So, is there a way to cast like this? I've tried putting "(int)" in every location I could think of, but none of them seem to be valid C++ :(</p>
