Skip to content

Add explicit discussion of generated member functions#60

Merged
jbcoe merged 1 commit intomainfrom
generated-structural-subtyping
Apr 8, 2026
Merged

Add explicit discussion of generated member functions#60
jbcoe merged 1 commit intomainfrom
generated-structural-subtyping

Conversation

@jbcoe
Copy link
Copy Markdown
Owner

@jbcoe jbcoe commented Apr 8, 2026

No description provided.

Copy link
Copy Markdown
Collaborator

@nbx8 nbx8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updates.

@jbcoe jbcoe merged commit 151b2e9 into main Apr 8, 2026
5 checks passed
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the WG21 draft proposal document to add an explicit foreword and a new section describing how protocol / protocol_view generate member functions from an interface type.

Changes:

  • Add a new “Foreword” section describing the early-stage status and intent of the proposal.
  • Replace the previous “Examples” placeholder with a “Generated structural subtyping” section and illustrative code snippets.
  • Add a short note about current reference-implementation code generation vs. potential compiler/static-reflection approaches.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


## Foreword

This is a very early stage design which we are sharing to further discussion
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foreword wording is ungrammatical: “sharing to further discussion” should be “sharing to further the discussion” (or similar).

Suggested change
This is a very early stage design which we are sharing to further discussion
This is a very early stage design which we are sharing to further the discussion

Copilot uses AI. Check for mistakes.
Comment on lines +87 to +90
For a given struct, the corresponding `protocol` and `protocol_view` will
implement all the public non-virtual, non-template member functions with
identical constexpr, noexcept and const-qualification.

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section says generated members have “identical constexpr, noexcept and const-qualification”, but the example doesn’t match (e.g., I::func1(double) is non-const while the generated func1 shown is const). Either adjust the claim or fix the example signatures to keep const-qualification identical.

Copilot uses AI. Check for mistakes.
Comment on lines +104 to +105
template <typename Allocator>
class protocol<I, Allocator=std::allocator<void>> {
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shown specialization class protocol<I, Allocator=std::allocator<void>> isn’t valid C++ syntax for a partial specialization (default arguments belong on the template parameter, and the specialization argument list shouldn’t assign). Consider writing it as template <typename Allocator = std::allocator<void>> class protocol<I, Allocator> { ... } (or equivalent).

Suggested change
template <typename Allocator>
class protocol<I, Allocator=std::allocator<void>> {
template <typename Allocator = std::allocator<void>>
class protocol<I, Allocator> {

Copilot uses AI. Check for mistakes.
Comment on lines +119 to +122
```c++
template <typename Allocator>
class protocol_view<I> {
// Constructors - see technical specification below.
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protocol_view is presented as having an Allocator template parameter here (template <typename Allocator> class protocol_view<I>), but elsewhere in the document (and in the reference implementation) protocol_view only takes the interface type. This example should be a full specialization (template <> class protocol_view<I> { ... }) without an allocator parameter.

Copilot uses AI. Check for mistakes.
```

```c++
template <typename Allocator>
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above for protocol_view<const I>: it’s shown as template <typename Allocator> but should be a full specialization of protocol_view (no allocator template parameter).

Suggested change
template <typename Allocator>

Copilot uses AI. Check for mistakes.
### Minimal API examples
// structural-subtype const member functions.
std::string func0(std::string_view) const noexcept;
double func1(double) const;
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the protocol_view<const I> example, func1(double) const is listed even though I::func1(double) in the interface example is non-const. If protocol_view<const T> only exposes const-qualified interface functions, this should likely only include func0(...) const noexcept (and omit non-const members like func1/func2).

Suggested change
double func1(double) const;

Copilot uses AI. Check for mistakes.
## Foreword

This is a very early stage design which we are sharing to further discussion
of design differences with a series of competing proposals for structural-subtyping.
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terminology is inconsistent here: the rest of the draft uses “structural subtyping” (no hyphen), but this sentence uses “structural-subtyping”. Consider making it consistent with the rest of the document.

Suggested change
of design differences with a series of competing proposals for structural-subtyping.
of design differences with a series of competing proposals for structural subtyping.

Copilot uses AI. Check for mistakes.
@jbcoe jbcoe deleted the generated-structural-subtyping branch April 8, 2026 22:31
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