Decide one rule for which `protocol` operations are members and which are hidden friends
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
- 35/100
- Tipo di issue
- Refactoring
- Chiarezza
- Da chiarire
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- backend-api-design, documentation
Direzione di ricerca
Start with DRAFT.md's "Reserved member names" section, then inspect #449's reserved_member_names and its guard test. Compare the four proposed rules and the related discussion in #194 before choosing one. Done means the rule is decided, DRAFT.md and the P3019 divergence are updated, and the related code and guard test match the choice.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
From the review of #449: https://github.com/jbcoe/cc-protocol/pull/449#issuecomment-5751922382
protocol follows polymorphic for some operations and not for others:
| Operation | polymorphic |
protocol |
|---|---|---|
swap |
member and hidden friend | member and hidden friend |
get_allocator |
member | member |
allocator_type |
member type | member type |
valueless_after_move |
member | hidden friend (#394, #395) |
target_type, protocol_cast |
none | hidden friends (#314, #306) |
Every member reserves a name an interface cannot use (#318, #449). valueless_after_move became a hidden friend to reserve one name fewer. swap stays a member because p.swap(pp) and swap(p, pp) should both work and agree, as on polymorphic. The parity argument that keeps swap a member would also have kept valueless_after_move one, and the reserved-name argument that moved valueless_after_move would also move swap, which already has a hidden-friend form.
jbcoe's replies after #449 merged (first, second) add two points. valueless_after_move is unusual enough that users bring no member-call expectation from polymorphic, unlike swap. And a hidden friend leaves the name free for the interface, which is a hazard for this name in particular:
struct I {
bool valueless_after_move() const;
};
xyz::protocol<I> p(std::in_place_type<T>);
auto q = std::move(p);
valueless_after_move(p); // hidden friend: true
p.valueless_after_move(); // generated member: calls through a valueless protocol, undefined behaviour
The interface is accepted today, because reserved_member_names holds only the three member names. No interface is likely to need the name, so rejecting it costs little. target_type and protocol_cast are hidden friends too, but an interface member with one of those names is no more dangerous than any other forwarded call.
Options:
- Parity with
polymorphic. Makevalueless_after_movea member again and reserve it. Code written againstpolymorphicworks unchanged withprotocol; four reserved names. - Fewest reserved names. Drop the member
swapand makeget_allocatora hidden friend. Onlyallocator_typestays reserved, whichuses_allocatorneeds. - Keep today's split and state the rule: an operation
polymorphicoffers in a hidden-friend form, or thatprotocoladds, is a hidden friend only; onepolymorphicoffers only as a member keeps the member. By that rulevalueless_after_moveis the exception and needs its own sentence in DRAFT.md. - Keep today's split and reserve
valueless_after_moveanyway.reserved_member_namesgains the name, and the guard testReservedMemberNamesAreThePublicMembersOfProtocolallows that one extra. DRAFT.md's sentence that a hidden friend "reserves no name" changes to say why this one is reserved. The rejection is per interface, so it applies to the views too.
Options 1 and 4 remove the hazard; 2 and 3 keep it.
Whichever is chosen, DRAFT.md's "Reserved member names" has to give the rule, and the divergence from P3019 belongs with the others in #194. #449's reserved_member_names and its guard test follow the choice mechanically.
- 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