diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-10-17 22:08:55 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-10-17 22:08:55 +0000 |
commit | e2fc01ea8d682187df2026c5ffd6fdd2425b2ad2 (patch) | |
tree | aab66a2ffb5ffb152b779f43836f7da4fbb88233 /include | |
parent | 790a03cfdedbb0aea34a9716c9925758092aa261 (diff) | |
download | external_llvm-e2fc01ea8d682187df2026c5ffd6fdd2425b2ad2.zip external_llvm-e2fc01ea8d682187df2026c5ffd6fdd2425b2ad2.tar.gz external_llvm-e2fc01ea8d682187df2026c5ffd6fdd2425b2ad2.tar.bz2 |
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
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/AlignOf.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Support/AlignOf.h b/include/llvm/Support/AlignOf.h index f27ecdd..0911bb8 100644 --- a/include/llvm/Support/AlignOf.h +++ b/include/llvm/Support/AlignOf.h @@ -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 |