[PATCH] D51872: isPodLike: handle tuple and array

JF Bastien via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 10 12:40:44 PDT 2018


jfb updated this revision to Diff 164732.
jfb added a comment.

- Fix think-o.


Repository:
  rL LLVM

https://reviews.llvm.org/D51872

Files:
  include/llvm/Support/type_traits.h


Index: include/llvm/Support/type_traits.h
===================================================================
--- include/llvm/Support/type_traits.h
+++ include/llvm/Support/type_traits.h
@@ -15,6 +15,8 @@
 #define LLVM_SUPPORT_TYPE_TRAITS_H
 
 #include "llvm/Support/Compiler.h"
+#include <array>
+#include <tuple>
 #include <type_traits>
 #include <utility>
 
@@ -48,11 +50,22 @@
 #endif
 };
 
-// std::pair's are pod-like if their elements are.
+// These containers are POD-like if their elements are.
 template<typename T, typename U>
 struct isPodLike<std::pair<T, U>> {
   static const bool value = isPodLike<T>::value && isPodLike<U>::value;
 };
+template <> struct isPodLike<std::tuple<>> { static const bool value = true; };
+template <typename T> struct isPodLike<std::tuple<T>> {
+  static const bool value = isPodLike<T>::value;
+};
+template <typename T, typename... Ts> struct isPodLike<std::tuple<T, Ts...>> {
+  static const bool value =
+      isPodLike<T>::value && isPodLike<std::tuple<Ts...>>::value;
+};
+template <typename T, std::size_t S> struct isPodLike<std::array<T, S>> {
+  static const bool value = isPodLike<T>::value;
+};
 
 /// Metafunction that determines whether the given type is either an
 /// integral type or an enumeration type, including enum classes.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51872.164732.patch
Type: text/x-patch
Size: 1293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180910/a5fecaf2/attachment.bin>


More information about the llvm-commits mailing list