[Interest] QVector / std::vector and memory alignment
Philippe
philwave at gmail.com
Fri Dec 30 14:03:57 CET 2016
> Il 29/12/2016 13:03, Thiago Macieira ha scritto:
> > How is it ia win for std::vector to achieve next year what QVector has done
> > for the past 7 or 8?
>
> Because with std::vector it has been possible for the last 16 years (by
> using a custom allocator), _and_ this behaviour has been well-defined by
> a Standard (unlike QVector, whose behaviour has always been undocumented
> / implementation defined, and possibly changed between Qt 3/4/5 and
> maybe will change again in Qt 6).
What is the logic of the C++ standard to introduce a new keyword (alignas) and have default containers ignoring them?...
From my POV, QVector succeeds where the standard std::vector fails.
Yes, using a custom allocator is possible.
But this another case where Qt succeeds in its philosohphy of easing programming.
I just wish the Qt behaviour could be officialy documented. That was my
original query, actually.
>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
You might be right about that (hopefully), but the quoted document
mentions operator new with a new alignment capability, but container
allocators are not mentionned (AFAICS)
Philippe
More information about the Interest
mailing list