[llvm-commits] [llvm] r43096 - /llvm/trunk/include/llvm/Support/AlignOf.h

Ted Kremenek kremenek at apple.com
Wed Oct 17 15:08:56 PDT 2007


Author: kremenek
Date: Wed Oct 17 17:08:55 2007
New Revision: 43096

URL: http://llvm.org/viewvc/llvm-project?rev=43096&view=rev
Log:
Added template function alignof() which provides a clean
function-based interface to getting the alignment of a type.

Modified:
    llvm/trunk/include/llvm/Support/AlignOf.h

Modified: llvm/trunk/include/llvm/Support/AlignOf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/AlignOf.h?rev=43096&r1=43095&r2=43096&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/AlignOf.h (original)
+++ llvm/trunk/include/llvm/Support/AlignOf.h Wed Oct 17 17:08:55 2007
@@ -38,6 +38,13 @@
 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





More information about the llvm-commits mailing list