[Allocator] Constrain the Deallocate templated overloads to only apply
[oota-llvm.git] / include / llvm / Support / Allocator.h
index 4da7acefb68c2d5e97afc5cf76499d4840b90daf..d96c8f254cc92fde54f2c3bf95af89cbfc2d9dda 100644 (file)
@@ -97,12 +97,15 @@ public:
   }
 
   /// \brief Deallocate space for one object without destroying it.
-  template <typename T> void Deallocate(T *Ptr) {
+  template <typename T>
+  typename std::enable_if<sizeof(T) != 0, void>::type Deallocate(T *Ptr) {
     Deallocate(static_cast<const void *>(Ptr));
   }
 
   /// \brief Allocate space for an array of objects without constructing them.
-  template <typename T> void Deallocate(T *Ptr, size_t /*Num*/) {
+  template <typename T>
+  typename std::enable_if<sizeof(T) != 0, void>::type
+  Deallocate(T *Ptr, size_t /*Num*/) {
     Deallocate(static_cast<const void *>(Ptr));
   }
 };