<p>Is there any way of doing parallel assignment in C++? Currently, the below compiles (with warnings)</p>

<pre><code>#include &lt;iostream&gt; 

int main() { 
  int a = 4;
  int b = 5;
  a, b = b, a;
  std::cout &lt;&lt; "a: " &lt;&lt; a &lt;&lt; endl
            &lt;&lt; "b: " &lt;&lt; b &lt;&lt; endl;

  return 0;
}
</code></pre>

<p>and prints:</p>

<pre><code>a: 4
b: 5
</code></pre>

<p>What I'd like it to print ... if it weren't obvious, is:</p>

<pre><code>a: 5
b: 4
</code></pre>

<p>As in, say, ruby, or python.</p>

Or Perl. But no, it's not possible (as far as I'm aware), you need to use a temporary variable, as in:
```
```
int a = 4;
int b = 5;

{
    int tmp = a;
    a = b;
    b = tmp;
}
```
```
FYI, internally those languages (or Perl atleast) create a temporary list
```
{ a, b }
```
, then assign the list to the two variables. In other words, this is atleast as performant, if only a little more messy.