From dc2e570411bb1b1345a6b9840050aca823835a81 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 15 Dec 2009 07:40:44 +0000 Subject: 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 --- include/llvm/ADT/SmallVector.h | 7 ++++++ include/llvm/Support/type_traits.h | 44 +++++++++++++++----------------------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index f3b4533..46d6b67 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -46,6 +46,13 @@ namespace std { namespace llvm { +/// SmallVectorBase - This is all the non-templated stuff common to all +/// SmallVectors. +class SmallVectorBase { + +}; + + /// SmallVectorImpl - This class consists of common code factored out of the /// SmallVector class to reduce code duplication based on the SmallVector 'N' /// template parameter. 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 -struct isPodLike { - static const bool value = false; -}; - -// pointers are all pod-like. -template -struct isPodLike { 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 { static const bool value = true; }; -template <> struct isPodLike { static const bool value = true; }; -template <> struct isPodLike { static const bool value = true; }; -template <> struct isPodLike { - static const bool value = true; -}; - - -// pairs are pod-like if their elements are. -template -struct isPodLike > { - static const bool value = isPodLike::value & isPodLike::value; -}; namespace dont_use { @@ -77,6 +50,23 @@ struct is_class public: enum { value = sizeof(char) == sizeof(dont_use::is_class_helper(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 +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::value; +}; + +// std::pair's are pod-like if their elements are. +template +struct isPodLike > { + static const bool value = isPodLike::value & isPodLike::value; +}; + /// \brief Metafunction that determines whether the two given types are /// equivalent. -- cgit v1.1