diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-04-15 06:29:04 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-04-15 06:29:04 +0000 |
commit | d82d4cc3567e896fad35372adba9a676c7776cd0 (patch) | |
tree | e7855183a7e653d059cd23051196ac8c313c5255 /llvm | |
parent | 7620b315684b3140da288d882affea2ba18192d0 (diff) | |
download | bcm5719-llvm-d82d4cc3567e896fad35372adba9a676c7776cd0.tar.gz bcm5719-llvm-d82d4cc3567e896fad35372adba9a676c7776cd0.zip |
[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.
llvm-svn: 206251
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/Support/Allocator.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/include/llvm/Support/Allocator.h b/llvm/include/llvm/Support/Allocator.h index 4da7acefb68..d96c8f254cc 100644 --- a/llvm/include/llvm/Support/Allocator.h +++ b/llvm/include/llvm/Support/Allocator.h @@ -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)); } }; |