Get ConcurrentSkipList functional
authorChristopher Dykes <cdykes@fb.com>
Sat, 3 Dec 2016 00:45:01 +0000 (16:45 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Sat, 3 Dec 2016 00:53:29 +0000 (16:53 -0800)
Summary:
MSVC was getting thoroughly confused while trying to eval the constexpr function, so switch it to a template instead.
MSVC was also failing to wrap it's head around what a NodeRecycler is, so delay its resolution via typename.

Reviewed By: yfeldblum

Differential Revision: D3478755

fbshipit-source-id: f687f4538fb12ef8eee525557f4cc988a09e714d

folly/ConcurrentSkipList-inl.h
folly/ConcurrentSkipList.h

index e4144bcbfb57dfaa035ace57a2f163ac62f4dbcf..a0dab2f3c92094d2c6dc7503f962796b96e44ef3 100644 (file)
@@ -70,10 +70,9 @@ class SkipListNode : private boost::noncopyable {
   }
 
   template<typename NodeAlloc>
-  static constexpr bool destroyIsNoOp() {
-    return IsArenaAllocator<NodeAlloc>::value &&
-           boost::has_trivial_destructor<SkipListNode>::value;
-  }
+  struct DestroyIsNoOp : std::integral_constant<bool,
+    IsArenaAllocator<NodeAlloc>::value &&
+    boost::has_trivial_destructor<SkipListNode>::value> { };
 
   // copy the head node to a new head node assuming lock acquired
   SkipListNode* copyHead(SkipListNode* node) {
@@ -230,7 +229,7 @@ class NodeRecycler;
 
 template<typename NodeType, typename NodeAlloc>
 class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if<
-  !NodeType::template destroyIsNoOp<NodeAlloc>()>::type> {
+  !NodeType::template DestroyIsNoOp<NodeAlloc>::value>::type> {
  public:
   explicit NodeRecycler(const NodeAlloc& alloc)
     : refs_(0), dirty_(false), alloc_(alloc) { lock_.init(); }
@@ -316,7 +315,7 @@ class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if<
 // to save on ConcurrentSkipList size.
 template<typename NodeType, typename NodeAlloc>
 class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if<
-  NodeType::template destroyIsNoOp<NodeAlloc>()>::type> {
+  NodeType::template DestroyIsNoOp<NodeAlloc>::value>::type> {
  public:
   explicit NodeRecycler(const NodeAlloc& alloc) : alloc_(alloc) { }
 
index 2f8f02549d90c29d5ad911b3cb76e7865f42de66..31ca1d1d5f72b3c0cf380f3715c8b0d85be9dfb2 100644 (file)
@@ -195,7 +195,7 @@ class ConcurrentSkipList {
   //===================================================================
 
   ~ConcurrentSkipList() {
-    /* static */ if (NodeType::template destroyIsNoOp<NodeAlloc>()) {
+    /* static */ if (NodeType::template DestroyIsNoOp<NodeAlloc>::value) {
       // Avoid traversing the list if using arena allocator.
       return;
     }