Open
Conversation
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.
…otocol into dev-twon-clang-tidy-reviewdog
…otocol into dev-twon-clang-tidy-reviewdog
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.
No description provided.