[llvm-commits] [llvm] r91425 - in /llvm/trunk/include/llvm: ADT/SmallVector.h Support/type_traits.h
Chris Lattner
sabre at nondot.org
Mon Dec 14 23:40:44 PST 2009
Author: lattner
Date: Tue Dec 15 01:40:44 2009
New Revision: 91425
URL: http://llvm.org/viewvc/llvm-project?rev=91425&view=rev
Log:
improve isPodLike to know that all non-class types are pod.
Modified:
llvm/trunk/include/llvm/ADT/SmallVector.h
llvm/trunk/include/llvm/Support/type_traits.h
Modified: llvm/trunk/include/llvm/ADT/SmallVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=91425&r1=91424&r2=91425&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallVector.h Tue Dec 15 01:40:44 2009
@@ -46,6 +46,13 @@
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.
Modified: llvm/trunk/include/llvm/Support/type_traits.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/type_traits.h?rev=91425&r1=91424&r2=91425&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/type_traits.h (original)
+++ llvm/trunk/include/llvm/Support/type_traits.h Tue Dec 15 01:40:44 2009
@@ -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 @@
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.
More information about the llvm-commits
mailing list