]> granicus.if.org Git - llvm/commitdiff
Add PointerLikeTypeTraits for const things, as long as there is one for the non-const...
authorDaniel Berlin <dberlin@dberlin.org>
Tue, 7 Mar 2017 18:47:50 +0000 (18:47 +0000)
committerDaniel Berlin <dberlin@dberlin.org>
Tue, 7 Mar 2017 18:47:50 +0000 (18:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297181 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PointerLikeTypeTraits.h

index 9ff894edbeb06a5256f42e7037589db1b2149782..521a49684e45a77e37f29f8f88bee972eb3e0c89 100644 (file)
@@ -60,6 +60,20 @@ public:
   enum { NumLowBitsAvailable = 2 };
 };
 
+// Provide PointerLikeTypeTraits for const things.
+template <typename T> class PointerLikeTypeTraits<const T> {
+  typedef PointerLikeTypeTraits<T> NonConst;
+
+public:
+  static inline const void *getAsVoidPointer(const T P) {
+    return NonConst::getAsVoidPointer(P);
+  }
+  static inline const T getFromVoidPointer(const void *P) {
+    return NonConst::getFromVoidPointer(const_cast<void *>(P));
+  }
+  enum { NumLowBitsAvailable = NonConst::NumLowBitsAvailable };
+};
+
 // Provide PointerLikeTypeTraits for const pointers.
 template <typename T> class PointerLikeTypeTraits<const T *> {
   typedef PointerLikeTypeTraits<T *> NonConst;