I have a value that I want to align to a given alignment, ie increase the value to the next multiple of the alignment if it is not already aligned.
What is a concise way to do this in C++?
eg
int x;
int alignment;
int y = ???; // align x to alignment
Lets say alignment is
awhere
kis an integer (sokais a multiple of alignment)First find the remainder
r = x%athen increment x to next multiple
y = x + (a-r)But if r = 0, then y = x
So finally