What are the alignas and alignof keywords used for?

前端 未结 1 470
情话喂你
情话喂你 2021-02-15 11:48

I\'m having trouble understand what the purpose of the alignas and alignof keywords are, and I\'m not quite sure I fully understand what alignment is.<

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-15 12:04

    Some special types must be aligned at more bytes than usual- for example, matrices must be aligned at 16bytes on x86 for the most efficient copying to the GPU. SSE vector types can behave this way too. As such, if you want to make a container type, then you must know the alignment requirements of the type you're trying to contain or allocate.

    0 讨论(0)
提交回复
热议问题