What is the best practice for swapping __m128i variables?
__m128i
The background is a compile error under Sun Studio 12.2, which is a C++03 compiler. __m1
__m1
swap via memcpy?
memcpy
#include #include template void memswap(T& a, T& b) { T t; std::memcpy(&t, &a, sizeof(t)); std::memcpy(&a, &b, sizeof(t)); std::memcpy(&b, &t, sizeof(t)); } int main() { __m128i x; __m128i y; memswap(x, y); return 0; }