I'm writing a program using Qt5, and I need to allocate a QVector <float>
having its data()
pointer 32-byte aligned.
Is there anyway I could do this without modifying the Qt library itself?
My code looks something like this:
QVector <float> vec;
vec.resize(n);
float *wricker_ptr = wricker.data(); // this should be 32-byte aligned
for (int i=0; i<n; i++)
{
wricker_ptr[i] = /* some computed value */;
}
I'm using Intel's C++ Compiler.
Two solutions come to mind:
std::vector
and a suitable allocator. QVector
's data payload is allocated with alignof(T)
.¹ QVector<__m256i>
or similar and reinterpret_cast
in and out. ¹ not entirely true, see http://thread.gmane.org/gmane.comp.lib.qt.devel/22326/focus=22596
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.