From 8bdae79536df887cbbb86136eaff09f2722a5914 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Wed, 30 Jan 2019 15:07:45 -0800 Subject: [PATCH] added rebind copy-ctor to STLAllocator this should fix the build on windows debug --- libs/utils/include/utils/Allocator.h | 3 +++ libs/utils/test/test_Allocators.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/libs/utils/include/utils/Allocator.h b/libs/utils/include/utils/Allocator.h index a16a376dcf..e67a8bfb00 100644 --- a/libs/utils/include/utils/Allocator.h +++ b/libs/utils/include/utils/Allocator.h @@ -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 + explicit STLAllocator(STLAllocator const& rhs) : mArena(rhs.mArena) { } + TYPE* allocate(std::size_t n) { return static_cast(mArena.alloc(n * sizeof(TYPE), alignof(TYPE))); } diff --git a/libs/utils/test/test_Allocators.cpp b/libs/utils/test/test_Allocators.cpp index 746e6740e1..01f5db2c03 100644 --- a/libs/utils/test/test_Allocators.cpp +++ b/libs/utils/test/test_Allocators.cpp @@ -308,6 +308,16 @@ TEST(AllocatorTest, STLAllocator) { EXPECT_TRUE(allocator != allocator2); EXPECT_TRUE(allocator == allocator); + STLAllocator::rebind::other charAllocator(arena); + EXPECT_TRUE(allocator == charAllocator); + + STLAllocator allocatorCopy(allocator); + EXPECT_TRUE(allocator == allocatorCopy); + + STLAllocator allocatorFromCharCopy(charAllocator); + EXPECT_TRUE(allocatorFromCharCopy == charAllocator); + + { #if !defined(WIN32) std::vector> vector(allocator);