[PATCH] D51872: isPodLike: handle tuple and array
JF Bastien via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 10 11:37:46 PDT 2018
jfb created this revision.
Herald added subscribers: llvm-commits, dexonsmith.
Just like isPodLike already handles pair, it should special-case tuple and array. This is really only useful for GCC before 5.0, so hopefully this workaround won't be around for long.
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,21 @@
#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<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.164708.patch
Type: text/x-patch
Size: 1274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180910/2bedee36/attachment.bin>
More information about the llvm-commits
mailing list