[PATCH] D19850: Make llvm::AlignedCharArrayUnion a variadic template.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 22:18:29 PDT 2016


ruiu added inline comments.

================
Comment at: include/llvm/Support/AlignOf.h:61-65
@@ -60,1 +60,7 @@
 
+template <typename T> struct AlignOfImplOne {
+  enum {
+    Alignment = static_cast<unsigned>(sizeof(AlignmentCalcImpl<T>) - sizeof(T))
+  };
+};
+
----------------
dblaikie wrote:
> What's the need for this separate helper rather than the usual variadic template recursion+base case below?
This is to avoid defining Alignment_GreaterEqual_* for both classes.

================
Comment at: include/llvm/Support/AlignOf.h:88
@@ -69,4 +87,3 @@
 ///  compile-time constant (e.g., for template instantiation).
-template <typename T>
-struct AlignOf {
+template <typename... Ts> struct AlignOf {
 #ifndef _MSC_VER
----------------
dblaikie wrote:
> I'm not sure we want to generalize the fundamental traits like this over variadic arguments & at this point would be a little more in favor of separating the variadic/max behavior from the basic trait. I don't insist on it, but wouldn't mind a 3rd opinion as it were (but I don't insist on that either). Maybe it does make sense to just make lots of traits inherently variadic if there's a single logical composition? (max rather than min, or sum, or anything else)
That is understandable. If this seems too much, I'll roll it back the last change so that we are not going to change AlignOf.


http://reviews.llvm.org/D19850





More information about the llvm-commits mailing list