[Allocator] MSVC apparantly has broken SFINAE context handling of
authorChandler Carruth <chandlerc@gmail.com>
Tue, 15 Apr 2014 08:02:29 +0000 (08:02 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 15 Apr 2014 08:02:29 +0000 (08:02 +0000)
'sizeof(T)' for T == void and produces a hard error. I cannot fathom why
this is OK. Oh well. switch to an explicit test for being the
(potentially qualified) void type, which is the only specific case I was
worried about. Hopefully this survives the libstdc++ build bots which
have limited type traits implementations...

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

include/llvm/Support/Allocator.h

index d96c8f254cc92fde54f2c3bf95af89cbfc2d9dda..034661f4bcd21d6a5e517e30fc11a69b2b7618a1 100644 (file)
@@ -98,13 +98,16 @@ public:
 
   /// \brief Deallocate space for one object without destroying it.
   template <typename T>
-  typename std::enable_if<sizeof(T) != 0, void>::type Deallocate(T *Ptr) {
+  typename std::enable_if<
+      std::is_same<typename std::remove_cv<T>::type, void>::value, 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>
-  typename std::enable_if<sizeof(T) != 0, void>::type
+  typename std::enable_if<
+      std::is_same<typename std::remove_cv<T>::type, void>::value, void>::type
   Deallocate(T *Ptr, size_t /*Num*/) {
     Deallocate(static_cast<const void *>(Ptr));
   }