Explore composing an interface from several structs
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 15/100
Hướng nghiên cứu
The question is whether protocol should accept an interface with base classes, rejecting it or counting inherited members, and how to settle that in the design. Start from the open questions on public and virtual bases and on duplicate signatures, and from the protocol template and the #390 and #98 threads it cites. Done means a decision on composition and narrowing, and a diagnostic for protocol<Both> if the chosen direction rejects base classes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Can one protocol require the member functions of several interface structs, the way a class can derive from several abstract bases? Today the only way is to write a new struct that repeats every member.
struct Drawable { void draw() const; };
struct Printable { void print() const; };
Two spellings:
- Inheritance on the interface.
struct Both : Drawable, Printable {};andprotocol<Both>. This is the sketch in #390.protocolkeeps its<I, Allocator>shape, and the composed interface has a name. - Several interface arguments.
protocol<Drawable, Printable>, asduckdoes (#98). The allocator is the second template parameter, so a list of interfaces has nowhere to go, and jbcoe was against this in #98 as inconsistent withpolymorphic.
Spelling 1 compiles today and does the wrong thing. Inherited members are ignored without a diagnostic: protocol<Both> has neither draw nor print, and every class type conforms to Both. Whatever is decided here, that should stop. Either reject an interface that has base classes, or count their members.
Questions:
- Is it worth having? Repeating the members in one struct works now. Composition saves the repetition and keeps the pieces in step.
- Which members count? Public bases only? If two bases declare the same signature, is that one requirement, or an error as it would be for name lookup? What about virtual and repeated bases?
- Does narrowing come with it? #390 wants a
protocol_view<Drawable>from aprotocol<Both>. Narrowing only to declared bases needs a vtable per base rather than per subset of members, so it may avoid the growth described in #98. The outline defers narrowing (#88), so composition could come first without it.
Suggested first step: reject an interface with base classes, so that the current behaviour cannot be relied on while this is decided.
- Ngôn ngữ chính
- C++
- Star
- 12
- Fork
- 4
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của jbcoe/cc-protocol
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
jbcoe/cc-protocol#507 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
jbcoe/cc-protocol#455 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jbcoe/cc-protocol#407 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
jbcoe/cc-protocol#194 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
jbcoe/cc-protocol#513 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của jbcoe/cc-protocol
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ai_p1 comp-sql-syntax
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
ClickHouse/ClickHouse#133888 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 66/100
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày