Skip to content

Commit

Permalink
fix: prj.03: make allocator copy constructible
Browse files Browse the repository at this point in the history
  • Loading branch information
j0tunn committed Oct 26, 2022
1 parent 247aad2 commit b60b57e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions projects/03/allocator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,10 @@ TEST_F(BulkAllocatorTest, OnRemoveAllElements_ShouldDeallocateWholeMemoryOnce) {

Mock::VerifyAndClearExpectations(&MemoryMgrMock::getInstance());
}

TEST_F(BulkAllocatorTest, CopyConstructor_ShuldInitiateContainerCopyWithClearAllocator) {
EXPECT_CALL(MemoryMgrMock::getInstance(), Allocate).Times(Exactly(2));

Map<2> m{{1, 1}, {2, 2}};
auto m2 = m;
}
4 changes: 3 additions & 1 deletion projects/03/bulk_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ class BulkAllocator {
~BulkAllocator() = default;

template <typename U>
BulkAllocator(const BulkAllocator<U, N>&) {}
BulkAllocator(const BulkAllocator<U, N>&) : memoryBlocks_() {}

BulkAllocator(const BulkAllocator<T, N>&) : memoryBlocks_() {}

T* allocate(std::size_t n) {
T* p = nullptr;
Expand Down

0 comments on commit b60b57e

Please sign in to comment.