Determining maximum possible alignment in C++

前端 未结 6 682
情歌与酒
情歌与酒 2021-01-31 18:58

Is there any portable way to determine what the maximum possible alignment for any type is?

For example on x86, SSE instructions require 16-byte alignm

6条回答
  •  生来不讨喜
    2021-01-31 19:34

    In C++0x, the Align template parameter of std::aligned_storage has a default argument of "default-alignment," which is defined as (N3225 §20.7.6.6 Table 56):

    The value of default-alignment shall be the most stringent alignment requirement for any C++ object type whose size is no greater than Len.

    It isn't clear whether SSE types would be considered "C++ object types."

    The default argument wasn't part of the TR1 aligned_storage; it was added for C++0x.

提交回复
热议问题