Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Sep 10, 2025

Summary

Resolves issue #78 by introducing readonly models for each collection concept that preserve const qualifiers instead of stripping them with std::remove_const_t.

  • CReadonlyDictionary: Readonly dictionary concept with only const methods (find, contains, empty, size)
  • CReadonlyList: Readonly list concept with only const methods (size, empty, indexing)
  • CReadonlySet: Readonly set concept with only const methods (find, contains, size, empty)

Key Changes

  1. CDictionary.h: Added CReadonlyDictionaryHelpFunction that uses const Self instead of std::remove_const_t<TRawSelf>
  2. CList.h: Added CReadonlyListHelpFunction with const-only operations
  3. CSet.h: Added CReadonlySetHelpFunction with const-only operations
  4. Test example: Demonstrates that const-qualified types now work properly with readonly concepts

Problem Solved

The original issue was that all collection concepts used std::remove_const_t<TRawSelf> which stripped away const qualifiers, making it impossible to define readonly models that only use const methods. This was described as a "small hack" that excluded readonly collections.

Solution

Instead of always removing the const qualifier, the new readonly concepts preserve it by using TRawSelf directly, ensuring that only const methods are required and available.

Test Plan

  • Compilation test passes with g++ -std=c++20
  • Static assertions verify const-qualified types work with readonly concepts
  • Static assertions verify non-const types still work with original concepts
  • All existing functionality preserved

🤖 Generated with Claude Code


Resolves #78

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #78
@konard konard self-assigned this Sep 10, 2025
konard and others added 2 commits September 10, 2025 18:36
Introduces CReadonlyDictionary, CReadonlyList, and CReadonlySet concepts that preserve const qualifiers instead of stripping them with std::remove_const_t. This enables proper readonly collections that only expose const methods.

- Add CReadonlyDictionaryHelpFunction that uses const Self instead of removing const qualifier
- Add CReadonlyListHelpFunction with const-only operations (size, empty, indexing)
- Add CReadonlySetHelpFunction with const-only operations (find, contains, size, empty)
- Add corresponding ReadonlyDictionary, ReadonlyList, and ReadonlySet structs
- Include test example demonstrating const qualification preservation

Fixes #78

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Add readonly[const] model to each collection's concepts Add readonly/const models for collection concepts Sep 10, 2025
@konard konard marked this pull request as ready for review September 10, 2025 15:40
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.

Add readonly[const] model to each collection's concepts

2 participants