-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #79: don't reuse m_buckets when allocator does not compare equal
m_buckets can only be reused when the allocators are equal. Otherwise we would deallocate with m_buckets with the incorrect allocator. Also bumped the version for the fix.
- Loading branch information
Showing
9 changed files
with
54 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <ankerl/unordered_dense.h> | ||
|
||
#define ENABLE_LOG_LINE | ||
#include <app/doctest.h> | ||
#include <app/print.h> | ||
|
||
#if defined(ANKERL_UNORDERED_DENSE_PMR) | ||
// windows' vector has different allocation behavior, macos has linker errors | ||
# if __linux__ | ||
|
||
using int_str_map = ankerl::unordered_dense::pmr::map<int, std::string>; | ||
|
||
// creates a map and moves it out | ||
auto return_hello_world(ANKERL_UNORDERED_DENSE_PMR::memory_resource* resource) { | ||
int_str_map map_default_resource(resource); | ||
map_default_resource[0] = "Hello"; | ||
map_default_resource[1] = "World"; | ||
return map_default_resource; | ||
} | ||
|
||
TEST_CASE("move_with_allocators") { | ||
int_str_map map_default_resource(ANKERL_UNORDERED_DENSE_PMR::new_delete_resource()); | ||
|
||
ANKERL_UNORDERED_DENSE_PMR::synchronized_pool_resource pool; | ||
|
||
// segfaults if m_buckets is reused | ||
{ | ||
map_default_resource = return_hello_world(&pool); | ||
REQUIRE(map_default_resource.contains(0)); | ||
} | ||
} | ||
|
||
# endif | ||
#endif |