Skip to content

Dev twon clang tidy reviewdog#1

Open
Twon wants to merge 16 commits intomainfrom
dev-twon-clang-tidy-reviewdog
Open

Dev twon clang tidy reviewdog#1
Twon wants to merge 16 commits intomainfrom
dev-twon-clang-tidy-reviewdog

Conversation

@Twon
Copy link
Copy Markdown
Owner

@Twon Twon commented Mar 26, 2026

No description provided.

Twon and others added 16 commits March 26, 2026 11:36
While `protocol<I>` manages the lifecycle of an erased object via value semantics (deep copies), `protocol_view<I>` allows zero-overhead observation at function boundaries without triggering allocations or transferring ownership.

1. Primary Template (`protocol.h`)
   - Added the primary template `template <typename T> class protocol_view;` alongside `protocol<T>`.

2. Code Generation (`scripts/protocol.j2`, `scripts/protocol_manual_vtable.j2`)
   - The generator now automatically emits both `protocol<I>` and `protocol_view<I>` specializations.
   - Generates two types of views per interface:
     - Mutable View (`protocol_view<I>`): Can invoke all methods.
     - Const View (`protocol_view<const I>`): Can only invoke `const` methods.
   - Implemented `protocol_const_concept_I` to allow types that only implement the `const` portion of an interface to satisfy the const-view requirements.

3. Structural Subtyping & Implicit Conversion
   - The view constructors are constrained by C++20 concepts (`protocol_concept_I` and `protocol_const_concept_I`).
   - Because `protocol<I>` exposes the identical method signatures as the interface it wraps, `protocol<I>` *itself* structurally satisfies the concept.

4. Const-Correctness Routing & Safety
   - Strict enforcement to prevent accidental mutation of `const` objects.
   - The compiler will reject (via concept failure) any attempt to construct a mutable `protocol_view<I>` from a `const` object.

5. Documentation
- Updated `README.md` to document `protocol_view` usage.
- Updated the ISO standard library proposal draft (`DRAFT.md`) to formally introduce `protocol_view` as the required mechanism for non-owning structural subtyping, contrasting it with the native raw pointers (`Base*`) used in nominal subtyping.
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.

3 participants