From 87f3870db9d92eca87e2f42c3537efe4bfb6e9c2 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 17 Oct 2007 22:08:55 +0000 Subject: 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 --- include/llvm/Support/AlignOf.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/llvm/Support/AlignOf.h') diff --git a/include/llvm/Support/AlignOf.h b/include/llvm/Support/AlignOf.h index f27ecdd713..0911bb84b3 100644 --- a/include/llvm/Support/AlignOf.h +++ b/include/llvm/Support/AlignOf.h @@ -38,6 +38,13 @@ template struct AlignOf { enum { Alignment = sizeof(AlignmentCalcImpl) - 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() returns the alignment of an int. +template +static inline unsigned alignof() { return AlignOf::Alignment; } } // end namespace llvm #endif -- cgit v1.2.3