VS 2012 / VC11中的对齐和STL [英] Alignment and the STL in VS 2012/VC11
问题描述
我有一个模糊的记忆STL有对齐结构(例如SIMD向量放在std ::向量)的麻烦,除非你指定一个自定义分配器。
I have a vague memory of the STL having trouble with aligned structs (e.g. SIMD vectors placed in a std::vector), unless you specify a custom allocator.
根据此文档,VS 2012 / VC11已部分支持 c ++ alignment 。这是否意味着VS STL实现现在可以处理对齐的结构,而不提供自定义分配器?
According to this document VS 2012/VC11 has partial support for c++ alignment. Does this mean that the VS STL implementation can handle aligned structs now, without providing a custom allocator?
推荐答案
否。这意味着VC ++编译器支持一种方法来为类型( __ declspec(align(N))
语法指定所需的对齐方式。 VC ++一直支持,它基本上被列为partial,因为我们有一些对齐相关的功能,看起来比说不支持更好。
No. It means that the VC++ compiler supports a method for specifying the required alignment for a type (the __declspec(align(N))
syntax). VC++ has always supported that, and it is basically listed as "partial" because "we have some alignment-related functionality, and it looks better than saying "not supported".
除此之外,我不知道C ++ 11对齐规范中的任何东西,这表明在标准库容器中的SIMD向量是保证工作的C ++ 11对齐基本上只是一个形式化的编译器已经做在这方面(就我所知,如果你能证明我错了,我会很乐意的)。
Apart from that, I'm not aware of anything in the C++11 alignment specification which indicates that SIMD vectors in a standard library container is guaranteed to work. C++11 alignment is basically just a formalization of what compilers already did, in this regard (as far as I know. I'd love if you could prove me wrong).
SIMD向量是标准调用的over-aligned types (见关于扩展对齐的部分)这意味着基本上我们保证什么,这完全取决于编译器如何/如果他们处理这种类型。
SIMD vectors are what the standard calls "over-aligned types" (see the part about "extended alignment"). What that means is basically "we guarantee nothing, and it's entirely up to the compiler how/if they handle such types.
换句话说,实现C ++ 11的这一部分不一定会改变SIMD对象的处理方式。
In other words, implementing this part of C++11 would not necessarily change how SIMD objects are handled.
这篇关于VS 2012 / VC11中的对齐和STL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!