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

Thiago Macieira thiago.macieira at intel.com
Fri Dec 30 14:23:53 CET 2016


Em sexta-feira, 30 de dezembro de 2016, às 14:03:57 BRST, Philippe escreveu:
> > 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?... 

Backwards compatibility. Both the containers and the regular operator new have 
worked in a given way for some time. Since they are so basic, changing them 
now may have unexpected consequences. To be on the safe side, an overload for 
new to support overalignment is provided.

I don't know (and don't care) about the containers.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Interest mailing list