operator [] (const unsigned int comp)
{
AssertIndexRange (comp, 4);
- return *(reinterpret_cast<double *>(&data)+comp);
+ // __m256d stores doubles in adjacent memory blocks. to access one double
+ // data field at a time, first cast the address of the given data field to
+ // void* and then back to double*.
+ return *(static_cast<double *>(static_cast<void *>(&data))+comp);
}
/**
operator [] (const unsigned int comp) const
{
AssertIndexRange (comp, 4);
- return *(reinterpret_cast<const double *>(&data)+comp);
+ return *(static_cast<const double *>(static_cast<const void *>(&data))+comp);
}
/**
operator [] (const unsigned int comp)
{
AssertIndexRange (comp, 8);
- return *(reinterpret_cast<float *>(&data)+comp);
+ return *(static_cast<float *>(static_cast<void *>(&data))+comp);
}
/**
operator [] (const unsigned int comp) const
{
AssertIndexRange (comp, 8);
- return *(reinterpret_cast<const float *>(&data)+comp);
+ return *(static_cast<const float *>(static_cast<const void *>(&data))+comp);
}
/**
operator [] (const unsigned int comp)
{
AssertIndexRange (comp, 2);
- return *(reinterpret_cast<double *>(&data)+comp);
+ return *(static_cast<double *>(static_cast<void *>(&data))+comp);
}
/**
operator [] (const unsigned int comp) const
{
AssertIndexRange (comp, 2);
- return *(reinterpret_cast<const double *>(&data)+comp);
+ return *(static_cast<const double *>(static_cast<const void *>(&data))+comp);
}
/**
operator [] (const unsigned int comp)
{
AssertIndexRange (comp, 4);
- return *(reinterpret_cast<float *>(&data)+comp);
+ return *(static_cast<float *>(static_cast<void *>(&data))+comp);
}
/**
operator [] (const unsigned int comp) const
{
AssertIndexRange (comp, 4);
- return *(reinterpret_cast<const float *>(&data)+comp);;
+ return *(static_cast<const float *>(static_cast<const void *>(&data))+comp);
}
/**