Added template function alignof() which provides a clean

function-based interface to getting the alignment of a type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43096 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2007-10-17 22:08:55 +00:00
parent 774577c1f9
commit 87f3870db9

View File

@ -38,6 +38,13 @@ template <typename T>
struct AlignOf {
enum { Alignment = sizeof(AlignmentCalcImpl<T>) - sizeof(T) };
};
/// alignof - A templated function that returns the mininum alignment of
/// of a type. This provides no extra functionality beyond the AlignOf
/// class besides some cosmetic cleanliness. Example usage:
/// alignof<int>() returns the alignment of an int.
template <typename T>
static inline unsigned alignof() { return AlignOf<T>::Alignment; }
} // end namespace llvm
#endif