Relative Content

Tag Archive for c++alignmentmemory-alignmentalignas

How to know the size of an aligned type including padding

I have a buffer with chunks that align to the cacheline size, but have arbitrary length, let’s say 100 bytes. It is clear to me that the buffer (vector) elements are aligned on cacheline borders, but then padding must be added for the next chunk to follow, so that it fulfills the alignment requirements as well. How then can I determine, without knowing the alignement requirement, what the size including padding is that an individual chunk must occupy?