From eb19b8f58b12532e736051fee46dcf2115a4888d Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 15 Apr 2014 06:29:04 +0000 Subject: [PATCH] [Allocator] Constrain the Deallocate templated overloads to only apply to types which we can compute the size of. The comparison with zero isn't actually interesting here, it's mostly about putting sizeof into a sfinae context. This is particular important for Deallocate as otherwise the void* overload can quickly become ambiguous. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206251 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Allocator.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index 4da7acefb68..d96c8f254cc 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -97,12 +97,15 @@ public: } /// \brief Deallocate space for one object without destroying it. - template void Deallocate(T *Ptr) { + template + typename std::enable_if::type Deallocate(T *Ptr) { Deallocate(static_cast(Ptr)); } /// \brief Allocate space for an array of objects without constructing them. - template void Deallocate(T *Ptr, size_t /*Num*/) { + template + typename std::enable_if::type + Deallocate(T *Ptr, size_t /*Num*/) { Deallocate(static_cast(Ptr)); } }; -- 2.34.1