[PATCH] D54472: Disable invalid isPodLike<> specialization

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 15 12:27:18 PST 2018


serge-sans-paille added inline comments.


================
Comment at: include/llvm/Support/type_traits.h:40-44
+#define LLVM_VERIFY_ISPODLIKE_CONSISTENCY(T)                                   \
+  static_assert(llvm::isPodLike<T>::value ==                                   \
+                    std::is_trivially_copyable<T>::value,                      \
+                "pod-like implies trivially copyable")
+
----------------
dblaikie wrote:
> Does the presence of this macro mean "no one should ever specialize isPodLike"? & if they don't, then its certain that isPodLike == is_trivially_copyable, by definition?
> 
> If so, then I'm not sure of the importance of the macro - we should just say "don't specialize isPodLike, ever & leave it at that, maybe?
Almost. It means « if you specialize ``isPodLike``, then make sure that for modern compiler, it does not conflict with std::is_trivially_copyable ».

Basically for modern compiler, we should have

``template<class T> using isPodLike = std::is_trivially_copiable<T>;``

However, some compilers supported by LLVM don't implement that feature. In my opinion, it is still valid to speicalize ``isPodLike`` to ensure decent performance in these case. But not at the cost of UB.


Repository:
  rL LLVM

https://reviews.llvm.org/D54472





More information about the llvm-commits mailing list