Is there any way of doing parallel assignment in C++? Currently, the below compiles (with warnings)
#include
int main() {
int a = 4;
There is no such function in the Standard Library. You could write a set of template functions :
template void ParAssign(T1& Lhs_1, T1 const& Rhs1);
template void ParAssign(T1& Lhs1, T2& Lhs2, T1 const& Rhs1, T2 const& Rhs2);
// etc.
ParAssign(a,b,
b,a);
That's non-trivial if there is aliasing, as in your swap example.