Convert value __m128i to std :: tuple
Imagine that after some SIMD calculations I am getting a __m128i
fourth field value with a useless null value. Is there a simple and portable way to turn the other three fields into std::tuple<int,int,int>
, keeping in mind that this is not a standard layout ?
+3
source to share
1 answer
Ugly but portable. I don't believe there is a quick solution as it std::tuple
doesn't have a specific memory layout. So we just copy these three values ββinto the tuple.
std::tuple<int, int, int> to_tuple(__m128i& value)
{
auto* ptr = reinterpret_cast<int*>(&value);
return std::make_tuple(ptr[0], ptr[1], ptr[2]);
}
Why do you need this? Perhaps you can work around your problem in a different way.
+1
source to share