diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-15 07:40:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-15 07:40:44 +0000 |
commit | dc2e570411bb1b1345a6b9840050aca823835a81 (patch) | |
tree | 07e7836d83840fa15fbbae6af99b38a9e9b912a2 /include/llvm/Support/type_traits.h | |
parent | 729a8acc9f2f4bd0751da20d0e85a8c02bdc5375 (diff) | |
download | external_llvm-dc2e570411bb1b1345a6b9840050aca823835a81.zip external_llvm-dc2e570411bb1b1345a6b9840050aca823835a81.tar.gz external_llvm-dc2e570411bb1b1345a6b9840050aca823835a81.tar.bz2 |
improve isPodLike to know that all non-class types are pod.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91425 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/type_traits.h')
-rw-r--r-- | include/llvm/Support/type_traits.h | 44 |
1 files changed, 17 insertions, 27 deletions
diff --git a/include/llvm/Support/type_traits.h b/include/llvm/Support/type_traits.h index 1f3f1e4..515295b 100644 --- a/include/llvm/Support/type_traits.h +++ b/include/llvm/Support/type_traits.h @@ -25,33 +25,6 @@ // works with VC7.0, but other interactions seem to fail when we use it. namespace llvm { - -/// isPodLike - This is a type trait that is used to determine whether a given -/// type can be copied around with memcpy instead of running ctors etc. -template <typename T> -struct isPodLike { - static const bool value = false; -}; - -// pointers are all pod-like. -template <typename T> -struct isPodLike<T*> { static const bool value = true; }; - -// builtin types are pod-like as well. -// There is probably a much better way to do this. -template <> struct isPodLike<char> { static const bool value = true; }; -template <> struct isPodLike<unsigned> { static const bool value = true; }; -template <> struct isPodLike<unsigned long> { static const bool value = true; }; -template <> struct isPodLike<unsigned long long> { - static const bool value = true; -}; - - -// pairs 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; -}; namespace dont_use { @@ -77,6 +50,23 @@ struct is_class public: enum { value = sizeof(char) == sizeof(dont_use::is_class_helper<T>(0)) }; }; + + +/// isPodLike - This is a type trait that is used to determine whether a given +/// type can be copied around with memcpy instead of running ctors etc. +template <typename T> +struct isPodLike { + // If we don't know anything else, we can (at least) assume that all non-class + // types are PODs. + static const bool value = !is_class<T>::value; +}; + +// std::pair's 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; +}; + /// \brief Metafunction that determines whether the two given types are /// equivalent. |