IDX-7031 Constrain cache generics with concepts#44
Open
dalloriam wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors cache/policy templates by moving template method implementations inline in headers and introduces new C++20 concepts to constrain cache generics (keys, hashers, measurement functors, etc.), aiming to provide clearer compile-time diagnostics and tighter API contracts.
Changes:
- Moved many template method definitions (cache + policies + bloom filter utilities) inline into their class declarations.
- Added
cachemere::detail::traitsconcepts (e.g.,Key,HasherFor,MeasureFor, etc.) and applied them to cache/policy templates. - Adjusted composite key hashing for basic strings.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| include/cachemere/policy/insertion_tinylfu.h | Apply concepts to template params; inline method implementations. |
| include/cachemere/policy/insertion_always.h | Apply concepts to template params; inline method implementations. |
| include/cachemere/policy/eviction_segmented_lru.h | Apply concepts to template params; inline method implementations; rename/reshape ticket type. |
| include/cachemere/policy/eviction_lru.h | Apply concepts to template params; inline method implementations. |
| include/cachemere/policy/eviction_gdsf.h | Apply concepts and introduce a cost functor concept; inline method implementations. |
| include/cachemere/policy/detail/hash_mixer.h | Constrain hasher template param; inline implementation. |
| include/cachemere/policy/detail/counting_bloom_filter.h | Inline implementation and refactor internals (shared index computation). |
| include/cachemere/policy/detail/bloom_filter.h | Inline implementation; adjust include ordering and add traits include. |
| include/cachemere/policy/constraint_memory.h | Apply concepts to template params; inline method implementations. |
| include/cachemere/policy/constraint_count.h | Apply concepts to template params; inline method implementations. |
| include/cachemere/detail/traits.h | Add new concepts for cache generics and call-site constraints. |
| include/cachemere/composite_key.h | Adjust string hashing to use c_str() for basic strings. |
| include/cachemere/cache.h | Constrain cache template params with concepts; move template method implementations inline; modernize SFINAE to requires. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dalloriam
force-pushed
the
feature/IDX-7025-try-insert
branch
from
May 27, 2026 12:51
067f16f to
8cf4125
Compare
dalloriam
force-pushed
the
feature/stricter-concepts
branch
from
May 27, 2026 12:52
521b590 to
cbb7f85
Compare
dalloriam
marked this pull request as ready for review
May 27, 2026 12:57
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
for every method.