Use constexpr initializers for AtomicHashArray Config
authorOrvid King <blah38621@gmail.com>
Fri, 31 Jul 2015 19:40:07 +0000 (12:40 -0700)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Fri, 31 Jul 2015 20:22:23 +0000 (13:22 -0700)
Summary: Closes #264

Modified by @sgolemon from the original PR to declare MSVC2015-final as the official minimum version, making the defines in the original PR unnecessary.

Reviewed By: @yfeldblum

Differential Revision: D2284130

Pulled By: @sgolemon

folly/AtomicHashArray.h
folly/AtomicLinkedList.h

index 7f12f862ca1af68e0fc5d5b0de24af5ad6e0886b..be78769563deac4c2dc130eeeed0da5265597399 100644 (file)
@@ -128,9 +128,15 @@ class AtomicHashArray : boost::noncopyable {
     int    entryCountThreadCacheSize;
     size_t capacity; // if positive, overrides maxLoadFactor
 
-    constexpr Config() : emptyKey((KeyT)-1),
-                         lockedKey((KeyT)-2),
-                         erasedKey((KeyT)-3),
+  private:
+    static constexpr KeyT kEmptyKey = (KeyT)-1;
+    static constexpr KeyT kLockedKey = (KeyT)-2;
+    static constexpr KeyT kErasedKey = (KeyT)-3;
+
+  public:
+    constexpr Config() : emptyKey(kEmptyKey),
+                         lockedKey(kLockedKey),
+                         erasedKey(kErasedKey),
                          maxLoadFactor(0.8),
                          growthFactor(-1),
                          entryCountThreadCacheSize(1000),
index eca8de16d9b32450cdab81876ae1c3834c6c9efe..f24746a5d1f6f8e0f7c234f75f5dfd2d1a99853a 100644 (file)
@@ -63,7 +63,7 @@ class AtomicLinkedList {
    * Note: list must be empty on destruction.
    */
   ~AtomicLinkedList() {
-    assert(head_ == nullptr);
+    assert(empty());
   }
 
   bool empty() const {