Make the type traits for a const pointer defer to those for a unqualified
authorJohn McCall <rjmccall@apple.com>
Wed, 23 Sep 2009 06:53:51 +0000 (06:53 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 23 Sep 2009 06:53:51 +0000 (06:53 +0000)
pointer, instead of providing independent values modelled on the default
implementation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82620 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PointerLikeTypeTraits.h

index b0edd3bd09f99d8049cf27b9d21a5d8f82366c85..d64993f54d1df8a70a4a8f24b3853d558440651a 100644 (file)
@@ -50,12 +50,16 @@ public:
 // Provide PointerLikeTypeTraits for const pointers.
 template<typename T>
 class PointerLikeTypeTraits<const T*> {
+  typedef PointerLikeTypeTraits<T*> NonConst;
+
 public:
-  static inline const void *getAsVoidPointer(const T* P) { return P; }
+  static inline const void *getAsVoidPointer(const T* P) {
+    return NonConst::getAsVoidPointer(const_cast<T*>(P));
+  }
   static inline const T *getFromVoidPointer(const void *P) {
-    return static_cast<const T*>(P);
+    return NonConst::getFromVoidPointer(const_cast<void*>(P));
   }
-  enum { NumLowBitsAvailable = 2 };
+  enum { NumLowBitsAvailable = NonConst::NumLowBitsAvailable };
 };
 
 // Provide PointerLikeTypeTraits for uintptr_t.