Skip to content

Add support for custom Hash, Equal, Allocator and custom value wrapper types#45

Open
vpetrigo wants to merge 79 commits intomasterfrom
feature/issue-44
Open

Add support for custom Hash, Equal, Allocator and custom value wrapper types#45
vpetrigo wants to merge 79 commits intomasterfrom
feature/issue-44

Conversation

@vpetrigo
Copy link
Copy Markdown
Owner

Address: #44

Add key_traits.hpp for automatic hash/equality detection
Add key_traits.hpp for ADL hash/equality detection
Provide a single include <caches/caches.hpp> that aggregates
key_traits, all cache policies (fifo, lfu, lru, no_eviction,
policy_interface) and the main core/cache.hpp. Includes Doxygen
documentation and usage examples.
Declare a FILE_SET named caches_headers and list public headers
explicitly under target_sources. Install that FILE_SET via
install(TARGETS caches FILE_SET caches_headers DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}) and remove the install(DIRECTORY ...) call.
Introduce pc_file and cmake_config_file variables and use them when
installing the pkgconfig and CMake config files.
Rename cache test targets:
lru_cache -> lru
fifo_cache -> fifo
lfu_cache -> lfu
nopolicy_cache -> no_eviction
Add a consolidated general cache test
Add extensive unit tests for LRU, LFU, FIFO, NoEviction and general
cache behaviour. Introduce test_helper.hpp and integrate its header into
test CMakeLists. Tests optionally support parallel_hashmap when
CUSTOM_HASHMAP is defined.
- include wrapper_policy.hpp and add WrapperPolicy template parameter
  with default wrapper_policy<Value>
- replace wrapped_value alias with WrapperPolicy::type and add
  wrapper_policy_type alias
- use WrapperPolicy::create(...) for emplace and updates instead of
  std::make_shared
- change TryGet to return default-constructed value_type when key is not
  found
- add test/wrapper_policy_tests.cpp with comprehensive tests for wrapper
  policies
- tests cover default traits, allocate_shared and custom allocator usage
- tests cover custom deleter, full-control wrappers, and user
  specializations
- tests include make_wrapper_traits, integration with LRU/FIFO/LFU, and
  lifetime behavior
- add #include "wrapper_policy.hpp" so caches.hpp has wrapper policy
  declarations
- set CXX_STANDARD 20 for each generated test target
- add gtl FetchContent declaration and make available (v1.2.0)
- link gtl into test targets and remove conditional parallel-hashmap
  fetch
- restrict test include dirs to ${GTEST_INCLUDE_DIRS}
- add -Wno-interference-size to non-MSVC compile options
- add wrapper_policy test to add_cache_test invocations
- remove #ifdef CUSTOM_HASHMAP wrapper and include gtl/intrusive.hpp and
  gtl/phmap.hpp
- replace phmap::node_hash_map alias with gtl::node_hash_map
- add gtl_shared_ptr alias for gtl::intrusive_ptr<Value>
- replace uses of wrapper_value_traits with wrapper_policy in multiple
  test files
- add caches/wrapper_policy.hpp include and <array> includes where
  needed
- update cache template instantiations to pass
  caches::default_wrapper<T> or wrapper_policy
- change constexpr std::array to const std::array<const char *, 5> for
  string literal arrays
- add CustomPtrWrapper test with custom_shared_ptr wrapper_policy and
  CustomInt type
- update file header comment in wrapper_policy_tests to use
  'wrapper_policy' wording
- add new header include/caches/wrapper_policy.hpp providing
  wrapper_policy template
- provide default wrapper_policy using std::shared_ptr and
  std::make_shared
- add smart_ptr_traits with std::shared_ptr specialization using
  make/allocate_shared
- add make_wrapper_policy helper for inline policy templates
- add pre-built policies: allocate_shared_wrapper,
  custom_deleter_wrapper
- add full_control_wrapper to combine custom allocator and deleter
  support
- include backward compatibility aliases default_wrapper and
  make_wrapper_traits
- add template alias phmap_flat_hash_map for gtl::flat_hash_map in
  test/test_helper.hpp
- define alias with template parameters Key, Value, Hash, Equal,
  Allocator to mirror node_hash_map alias
PhmapBackend

- add include "typed_backends.hpp" and parameterized test fixtures in
  fifo, lfu, lru, no_eviction
- replace per-file CUSTOM_HASHMAP typedefs with TestFixture::template
  cache_t aliases
- register Backends = ::testing::Types<StdBackend, PhmapBackend> and use
  TYPED_TEST_SUITE/TYPED_TEST
- include "test_helper.hpp" in general_tests.cpp and remove
  CUSTOM_HASHMAP phmap alias blocks
- update test bodies to construct caches via TestFixture cache_t while
  preserving assertions
- add new header test/typed_backends.hpp exposing two backends for gtest
  typed tests
- introduce StdBackend with template alias cache_t = caches::cache<Key,
  Value, Policy>
- introduce PhmapBackend with template alias cache_t using
  caches::key_traits, caches::wrapper_policy
  and phmap_node_hash_map as extra template parameters
- include caches/caches.hpp, caches/wrapper_policy.hpp and
  test_helper.hpp
- remove test/typed_backends.hpp which provided StdBackend and
  PhmapBackend aliases for typed tests
warnings

- update test/CMakeLists.txt: move -Wno-interference-size into
  GNU-specific generator expression
- remove typed_backends.hpp includes from fifo_tests.cpp, lru_tests.cpp,
  lfu_tests.cpp, no_eviction_tests.cpp
- delete numerous explanatory and section comment lines across test
  sources (general_tests.cpp, wrapper_policy_tests.cpp, ...)
- add include "caches/caches.hpp" and define StdBackend and PhmapBackend
  in test/test_helper.hpp
- bump Doxygen template header version from 1.8.17 to 1.16.1
- standardize capitalization and wording to use "Doxygen" in comments
- add usage notes for doxygen -x and doxygen -x_noenv in the header
- set PROJECT_NAME to Caches (unquoted) and add PROJECT_ICON entry
- add CREATE_SUBDIRS_LEVEL = 8 and expand comment explaining levels
- clarify CREATE_SUBDIRS behavior and recommend adjusting level when
  used
- extend OUTPUT_LANGUAGE list with additional languages and wording
  fixes
- add PYTHON_DOCSTRING = YES with explanation of default behavior
- reword several tag descriptions to clarify punctuation and behavior
- apply minor wording and formatting improvements across cmake Doxygen
  files
- update cmake/index.md.in header/intro to align with template changes
- upgrade actions/checkout usages from v4/v2 to v6 across workflows
- normalize submodules option quoting from 'true' to "true"
- compact matrix arrays formatting for os, tag and custom-hash-map
  entries
- add tag 21 to one tag matrix and add tag 15 to another tag matrix
- replace docs poetry install and mkdocs steps with
  astral-sh/setup-uv@v7 and single cmake build
- keep documentation publish command intact but moved to a single-line
  run
- add missing newline at end of ci.yml
- add api/cache/cache.md describing caches::cache with basic usage and
  template params
- add api/key_traits.md with ADL hash_value example and make_traits
  usage example
- add api/policy/lru.md, lfu.md, fifo.md, no_eviction.md and
  policy_interface.md for policies
- add api/wrapper_policy.md explaining default wrapper and how to
  provide custom wrappers
- add docs/mkdocs/uv.lock containing Python dependency lock for the
  mkdocs site
- update docs target to depend on doxy and docs_web
- add doxy custom target to run doxygen with Doxyfile in docs/doxygen
- add docs_web custom target to run `uv run mkdocs build --strict` in
  docs/mkdocs
- add include/caches/caches.hpp, include/caches/key_traits.hpp and
  include/caches/wrapper_policy.hpp to caches target_sources
- convert pyproject.toml from [tool.poetry] to PEP 621 [project] and
  bump version 0.0.4 → 0.0.5
- replace poetry build-system (poetry-core) with setuptools>=61 build
  backend
- remove docs/mkdocs/poetry.lock and delete autogenerated lockfile
  contents
- remove generated API markdown files under docs/mkdocs/docs/api
- update docs hooks to clean and copy Doxygen html into docs/doxygen
  with dirs_exist_ok
- update docs index to reference Doxygen API and remove per-class links
- update Doxyfile header from 1.8.17 to 1.16.1
- update LICENSE image src to use new OSI URL
- bump copyright year in mkdocs.yml to 2015-2026
- bump doxygen download from Release_1_9_6/doxygen-1.9.6 to
  Release_1_16_1/doxygen-1.16.1
- update PATH entry to reference doxygen-1.16.1/bin
- rename generate_documentation to copy_documentation
- remove doxygen and poetry/mkdocs build subprocess calls
- update main to call copy_documentation instead of
  generate_documentation
- move argparse import earlier and tempfile import later
- add .gitmodules entry for submodule deps/catch2 with url
  https://github.com/catchorg/Catch2.git
- add submodule at deps/catch2 pointing to v3.12.0
- ensure cmake args are preserved on Windows runners
- ensure lcov excludes deps/test under the build directory
- improve coverage accuracy in CI
- preserve repo root for coverage and artifact paths
- ensure BASE_DIR points to project root, not build directory
- enable libc++ support for clang matrix
- update coverage uploader
- prevent leftover artifacts
- reduce CI workspace clutter
- upload coverage.info to Codecov
- remove redundant ls/rm steps
- keep upload non-failing on error
- include debug symbols for coverage
- stabilize test diagnostics
- enable coverage tooling via uv and gcovr
- generate coverage with cmake target
- avoid creating and entering coverage directory
- keep lcov steps commented
- ensure codecov picks up coverage file
- avoid spurious CI failures
- disable search for uploads
- fail CI on codecov errors
- exercise on-erase callbacks across policies and phmap backend
- add constructor-with-policy coverage and rule-of-five checks
- add LRU eviction edge-case tests and tidy NoEviction test formatting
- exercise erase on missing keys across policies and key types
- validate wrapper allocation/deallocation on exceptions
- verify custom deleter and allocate_shared instance counts
wrapper_policy

- ensure deallocation uses the original allocator
- add construction guard to prevent leaks on exception
- adjust tests to treat deleters as destruction-only
  include/caches: refactor: allocator-aware deleters and RAII guard in
  wrapper_policy

- ensure deallocation uses the same allocator
- separate destruction from memory deallocation for custom deleters
- add RAII guard to avoid leaks on construction failure
- update tests to use destruction-only deleters and null-safe
  deallocation
- remove redundant header
- reduce unnecessary dependencies
@vpetrigo vpetrigo marked this pull request as ready for review January 30, 2026 22:49
- upload build/coverage.info to Coveralls
- use COVERALLS_TOKEN secret
targets

- reduce noise from exception throw branches
- improve accuracy of line-level coverage
- match action's expected input name
- restore Coveralls upload in CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant