added rebind copy-ctor to STLAllocator

this should fix the build on windows debug
This commit is contained in:
Mathias Agopian
2019-01-30 15:07:45 -08:00
committed by Mathias Agopian
parent 0bdb6b8a8a
commit 8bdae79536
2 changed files with 13 additions and 0 deletions

View File

@@ -739,6 +739,9 @@ public:
// from an Arena, avoiding to have to repeat the vector type.
STLAllocator(ARENA& arena) : mArena(arena) { } // NOLINT(google-explicit-constructor)
template<typename U>
explicit STLAllocator(STLAllocator<U, ARENA> const& rhs) : mArena(rhs.mArena) { }
TYPE* allocate(std::size_t n) {
return static_cast<TYPE *>(mArena.alloc(n * sizeof(TYPE), alignof(TYPE)));
}

View File

@@ -308,6 +308,16 @@ TEST(AllocatorTest, STLAllocator) {
EXPECT_TRUE(allocator != allocator2);
EXPECT_TRUE(allocator == allocator);
STLAllocator<int, Arena>::rebind<char>::other charAllocator(arena);
EXPECT_TRUE(allocator == charAllocator);
STLAllocator<int, Arena> allocatorCopy(allocator);
EXPECT_TRUE(allocator == allocatorCopy);
STLAllocator<int, Arena> allocatorFromCharCopy(charAllocator);
EXPECT_TRUE(allocatorFromCharCopy == charAllocator);
{
#if !defined(WIN32)
std::vector<int, STLAllocator<int, Arena>> vector(allocator);