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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 22:15:37 PDT 2016


dblaikie 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))
+  };
+};
+
----------------
What's the need for this separate helper rather than the usual variadic template recursion+base case below?

================
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
----------------
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)


http://reviews.llvm.org/D19850





More information about the llvm-commits mailing list