[Interest] QVector / std::vector and memory alignment

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Thu Dec 29 09:32:19 CET 2016


Il 29/12/2016 06:56, Philippe ha scritto:
> Sometimes there are discussions about what is best QVector vs
> std::vector, and here we have a good "plus" for QVector.

In C++17 std::vector (well, std::allocator) must honour overly-aligned
types:

> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0035r4.html

GCC 7 and Clang 4 already implement it.

Before C++17 you could've used an aligned allocator like Boost.Align.
QVector doesn't allow custom allocators, so here we have a win for
std::vector.

Cheers,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4007 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161229/e18c1534/attachment.bin>


More information about the Interest mailing list