forked from Tessil/sparse-map
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/fancy pointers #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4e65777
Started to add fancy pointer support to the sparse array class and a …
LukasKerk 083182e
Fixxed a bug in the move construction test.
LukasKerk 34b0549
Started to work on sparse_hash
LukasKerk 0dcc86a
Some more changes for the iterators.
LukasKerk 3e74155
Ported the set tests to work with maps. I could have generalized the …
LukasKerk a6c225d
Integrated boost::to_address directly into the code.
LukasKerk 4298884
A bit of tidy up. Now the fancy pointer tests are integrated into the…
LukasKerk 6435d76
added test for value() with fancy pointer
bigerl fb6c7e7
added missing const
bigerl fbd3603
Fixxed a bug in the OffsetAllocator, also did some work on erase.
LukasKerk 4eec685
added Remove_Const struct for overloading const_cast with @LukasKerk
bigerl 86226d7
Added the "const_cast" for boost offset pointers in its own header.
LukasKerk 251e076
Fixed a typo in a test output.
LukasKerk 6a148bf
Corrected comments.
LukasKerk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,24 @@ | ||
| #ifndef TSL_SPARSE_MAP_TESTS_BOOST_OFFSET_POINTER_H | ||
| #define TSL_SPARSE_MAP_TESTS_BOOST_OFFSET_POINTER_H | ||
|
|
||
| #include "sparse_hash.h" //needed, so the basic template is already included | ||
| #include <boost/interprocess/offset_ptr.hpp> | ||
|
|
||
| namespace tsl { | ||
| /* Template specialisation for a "const_cast" of a boost offset_ptr. | ||
| * @tparam PT PointedType | ||
| * @tparam DT DifferenceType | ||
| * @tparam OT OffsetType | ||
| * @tparam OA OffsetAlignment | ||
| */ | ||
| template <typename PT, typename DT, typename OT, std::size_t OA> | ||
| struct Remove_Const<boost::interprocess::offset_ptr<PT, DT, OT, OA>> { | ||
| template <typename T> | ||
| static boost::interprocess::offset_ptr<PT, DT, OT, OA> | ||
| remove(T const &const_iter) { | ||
| return boost::interprocess::const_pointer_cast<PT, DT, OT, OA>(const_iter); | ||
| } | ||
| }; | ||
| } // namespace tsl | ||
|
|
||
| #endif // TSL_SPARSE_MAP_TESTS_BOOST_OFFSET_POINTER_H |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -2,12 +2,17 @@ cmake_minimum_required(VERSION 3.8) | |
|
|
||
| project(tsl_sparse_map_tests) | ||
|
|
||
| add_executable(tsl_sparse_map_tests "main.cpp" | ||
| "custom_allocator_tests.cpp" | ||
| "policy_tests.cpp" | ||
| "popcount_tests.cpp" | ||
| "sparse_map_tests.cpp" | ||
| "sparse_set_tests.cpp") | ||
| add_executable(tsl_sparse_map_tests "main.cpp" | ||
| "custom_allocator_tests.cpp" | ||
| "policy_tests.cpp" | ||
| "popcount_tests.cpp" | ||
| "sparse_map_tests.cpp" | ||
| "sparse_set_tests.cpp" | ||
| "fancy_pointer/sparse_array_tests.cpp" | ||
| "fancy_pointer/sparse_hash_set_tests.cpp" | ||
| "fancy_pointer/CustomAllocator.h" | ||
| "fancy_pointer/sparse_hash_map_tests.cpp" | ||
| "../include/tsl/boost_offset_pointer.h") | ||
|
|
||
| target_compile_features(tsl_sparse_map_tests PRIVATE cxx_std_11) | ||
|
|
||
|
|
@@ -19,8 +24,8 @@ endif() | |
|
|
||
| # Boost::unit_test_framework | ||
| find_package(Boost 1.54.0 REQUIRED COMPONENTS unit_test_framework) | ||
| target_link_libraries(tsl_sparse_map_tests PRIVATE Boost::unit_test_framework) | ||
| target_link_libraries(tsl_sparse_map_tests PRIVATE Boost::unit_test_framework) | ||
|
|
||
| # tsl::sparse_map | ||
| add_subdirectory(../ ${CMAKE_CURRENT_BINARY_DIR}/tsl) | ||
| target_link_libraries(tsl_sparse_map_tests PRIVATE tsl::sparse_map) | ||
| target_link_libraries(tsl_sparse_map_tests PRIVATE tsl::sparse_map) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unnecessary whitespace change |
||
This file contains hidden or 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,46 @@ | ||
| /** @file | ||
| * @bief Home of a custom allocator for testing with fancy pointers. | ||
| */ | ||
|
|
||
| #ifndef TSL_SPARSE_MAP_TESTS_CUSTOMALLOCATOR_H | ||
| #define TSL_SPARSE_MAP_TESTS_CUSTOMALLOCATOR_H | ||
|
|
||
| #include <boost/interprocess/offset_ptr.hpp> | ||
|
|
||
| /** A custom allocator that simply wraps all pointers into boost offset ptr. | ||
| * It is used to check whether the implementation can handle Allocators using fancy pointers. | ||
| * @tparam T Typical Allocator parameter. | ||
| */ | ||
| template<typename T> | ||
| struct OffsetAllocator { | ||
| using value_type = T; | ||
| template <typename P> using offset_ptr = boost::interprocess::offset_ptr<P>; | ||
| using pointer = offset_ptr<value_type>; | ||
| using const_pointer = offset_ptr<const value_type>; | ||
| using void_pointer = offset_ptr<void>; | ||
| using const_void_pointer = offset_ptr<const void>; | ||
| using difference_type = typename offset_ptr<value_type>::difference_type; | ||
|
|
||
| OffsetAllocator() noexcept = default; | ||
| OffsetAllocator(OffsetAllocator const &) noexcept = default; | ||
| OffsetAllocator(OffsetAllocator &&) noexcept = default; | ||
| OffsetAllocator &operator=(OffsetAllocator const &) noexcept = default; | ||
| OffsetAllocator &operator=(OffsetAllocator &&) noexcept = default; | ||
| template<typename V> | ||
| OffsetAllocator(OffsetAllocator<V>) noexcept {} | ||
|
|
||
| pointer allocate(std::size_t n) { | ||
| return pointer(static_cast<T*>(::operator new(n*sizeof(T)))); | ||
| } | ||
| void deallocate(pointer p, std::size_t) noexcept { | ||
| ::operator delete(p.get()); | ||
| } | ||
| friend bool operator==(OffsetAllocator const &, OffsetAllocator const &) noexcept { | ||
| return true; | ||
| } | ||
| friend bool operator!=(OffsetAllocator const &l, OffsetAllocator const &r) noexcept { | ||
| return !(l == r); | ||
| } | ||
| }; | ||
|
|
||
| #endif //TSL_SPARSE_MAP_TESTS_CUSTOMALLOCATOR_H |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary whitespace change