diff --git a/src/lockfree.h b/src/lockfree.h index b555139d05..5954a13c3c 100644 --- a/src/lockfree.h +++ b/src/lockfree.h @@ -30,13 +30,13 @@ * we use this to avoid instantiating multiple free lists for objects of the * same size and it can be replaced by a variable template in C++14 * - * template - * boost::lockfree::stack lockfreeFreeList; + * template + * boost::lockfree::stack lockfreeFreeList; */ -template +template struct LockfreeFreeList { - using FreeList = boost::lockfree::stack>; + using FreeList = boost::lockfree::stack>; static FreeList& get() { static FreeList freeList; @@ -44,18 +44,24 @@ struct LockfreeFreeList } }; -template -class LockfreePoolingAllocator : public std::allocator +template +class LockfreePoolingAllocator { public: + template + struct rebind + { + using other = LockfreePoolingAllocator; + }; + LockfreePoolingAllocator() = default; - template ::value>::type> - explicit constexpr LockfreePoolingAllocator(const U&) {} + template + explicit constexpr LockfreePoolingAllocator(const LockfreePoolingAllocator&) {} using value_type = T; T* allocate(size_t) const { - auto& inst = LockfreeFreeList::get(); + auto& inst = LockfreeFreeList::get(); void* p; // NOTE: p doesn't have to be initialized if (!inst.pop(p)) { //Acquire memory without calling the constructor of T @@ -65,7 +71,7 @@ class LockfreePoolingAllocator : public std::allocator } void deallocate(T* p, size_t) const { - auto& inst = LockfreeFreeList::get(); + auto& inst = LockfreeFreeList::get(); if (!inst.bounded_push(p)) { //Release memory without calling the destructor of T //(it has already been called at this point)