Actually allow SFINAE to occur with setThreadName
authorChristopher Dykes <cdykes@fb.com>
Wed, 25 Jan 2017 00:15:19 +0000 (16:15 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 25 Jan 2017 00:17:54 +0000 (16:17 -0800)
Summary:
It wasn't actually SFINAE the way it was setup previously, which meant it was just a hard error under MSVC.
Whoops.

Reviewed By: yfeldblum

Differential Revision: D4453702

fbshipit-source-id: 5be600fb5ecdc8255795fefbd37c1fe26e7266dd

folly/ThreadName.h

index 018f8abc90b5ab071c220ef84e4b73c8424f275a..095088567d94ef2b062ca9e244eb4301bcb42360 100644 (file)
@@ -22,6 +22,7 @@
 #include <pthread.h>
 
 #include <folly/Range.h>
+#include <folly/Traits.h>
 
 namespace folly {
 
@@ -70,11 +71,10 @@ inline bool setThreadName(pthread_t id, StringPiece name) {
 }
 #endif
 
-template <>
-inline typename std::enable_if<
-    std::is_same<pthread_t, std::thread::native_handle_type>::value,
-    bool>::type
-setThreadName(std::thread::id id, StringPiece name) {
+template <
+    typename = folly::_t<std::enable_if<
+        std::is_same<pthread_t, std::thread::native_handle_type>::value>>>
+inline bool setThreadName(std::thread::id id, StringPiece name) {
   static_assert(
       sizeof(std::thread::native_handle_type) == sizeof(decltype(id)),
       "This assumes std::thread::id is a thin wrapper around "