Determining maximum possible alignment in C++

前端 未结 6 683
情歌与酒
情歌与酒 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

    Short of some maximally_aligned_t type that all compilers promised faithfully to support for all architectures everywhere, I don't see how this could be solved at compile time. As you say, the set of potential types is unbounded. Is the extra pointer indirection really that big a deal?

提交回复
热议问题