Explore composing an interface from several structs
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 15/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- C++
- Stelle
- 12
- Fork
- 4
- Merge medio
- 1g 11h
- PR unite (30g)
- 15
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di jbcoe/cc-protocol
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
jbcoe/cc-protocol#507 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
jbcoe/cc-protocol#455 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
jbcoe/cc-protocol#407 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
jbcoe/cc-protocol#194 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
jbcoe/cc-protocol#513 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di jbcoe/cc-protocol
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
ai_p1 comp-sql-syntax
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
ClickHouse/ClickHouse#133888 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
documentation good first issue
Difficoltà 2/5 Mezza giornata Idoneità per principianti 66/100
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno