<p dir="ltr">I think we end up relying on this for more than just copyable. We also skip destructor calls in some places etc.</p>
<p dir="ltr">Would it be better to change the users of this to use the more precise names? We can provide wrappers with version checks and defaulr fallbacks based on explicit specializations of the old trait.</p>
<p dir="ltr">Thoughts?</p>
<div class="gmail_quote">On Feb 20, 2015 8:26 AM, "Benjamin Kramer" <<a href="mailto:benny.kra@googlemail.com">benny.kra@googlemail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: d0k<br>
Date: Fri Feb 20 10:19:28 2015<br>
New Revision: 230021<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=230021&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=230021&view=rev</a><br>
Log:<br>
Base isPodLike on is_trivially_copyable for GCC 5 and MSVC<br>
<br>
It would be nice to get rid of the version checks here, but that will<br>
have to wait until libstdc++ is upgraded to 5.0 everywhere ...<br>
<br>
Modified:<br>
llvm/trunk/include/llvm/Support/type_traits.h<br>
<br>
Modified: llvm/trunk/include/llvm/Support/type_traits.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/type_traits.h?rev=230021&r1=230020&r2=230021&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/type_traits.h?rev=230021&r1=230020&r2=230021&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Support/type_traits.h (original)<br>
+++ llvm/trunk/include/llvm/Support/type_traits.h Fri Feb 20 10:19:28 2015<br>
@@ -28,9 +28,17 @@ namespace llvm {<br>
/// type can be copied around with memcpy instead of running ctors etc.<br>
template <typename T><br>
struct isPodLike {<br>
-#if __has_feature(is_trivially_copyable)<br>
+ // std::is_trivially copyable is available in libc++ with clang, libstdc++<br>
+ // that comes with GCC 5 and MSVC 2013.<br>
+#if (__has_feature(is_trivially_copyable) && defined(_LIBCPP_VERSION)) || \<br>
+ (defined(__GNUC__) && __GNUC__ >= 5) || defined(_MSC_VER)<br>
// If the compiler supports the is_trivially_copyable trait use it, as it<br>
// matches the definition of isPodLike closely.<br>
+ static const bool value = std::is_trivially_copyable<T>::value;<br>
+#elif __has_feature(is_trivially_copyable)<br>
+ // Use the internal name if the compiler supports is_trivially_copyable but we<br>
+ // don't know if the standard library does. This is the case for clang in<br>
+ // conjunction with libstdc++ from GCC 4.x.<br>
static const bool value = __is_trivially_copyable(T);<br>
#else<br>
// If we don't know anything else, we can (at least) assume that all non-class<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>