From f02969dfd3b7a9ac0b0cc8d8f84a12f92bb7ca7e Mon Sep 17 00:00:00 2001 From: Orvid King Date: Fri, 31 Jul 2015 12:40:07 -0700 Subject: [PATCH] Use constexpr initializers for AtomicHashArray Config 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 | 12 +++++++++--- folly/AtomicLinkedList.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/folly/AtomicHashArray.h b/folly/AtomicHashArray.h index 7f12f862..be787695 100644 --- a/folly/AtomicHashArray.h +++ b/folly/AtomicHashArray.h @@ -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), diff --git a/folly/AtomicLinkedList.h b/folly/AtomicLinkedList.h index eca8de16..f24746a5 100644 --- a/folly/AtomicLinkedList.h +++ b/folly/AtomicLinkedList.h @@ -63,7 +63,7 @@ class AtomicLinkedList { * Note: list must be empty on destruction. */ ~AtomicLinkedList() { - assert(head_ == nullptr); + assert(empty()); } bool empty() const { -- 2.34.1