NL.16 is ambiguous
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp, markdown
- Ambito
- documentation
Direzione di ricerca
Leggi la linea guida NL.16 e le discussioni citate negli issue #962, #977 e #980. Poi controlla il chiarimento precedente nel commit edbfc3b. L’issue propone di aggiungere uno dei due esempi di codice per esplicitare l’ordine preferito. Il lavoro è completato quando NL.16 indica chiaramente quale ordine è preferito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Previously discussed in #962, #977, #980.
The recommendation according to the guideline is:
When declaring a class use the following order
- types: classes, enums, and aliases (
using)- constructors, assignments, destructor
- functions
- data
Use the
publicbeforeprotectedbeforeprivateorder.
These are two different dimensions, kind (types, special member functions, functions, data) and access (public, protected, private), without clearly stating which takes priority.
Discussion from editors on previous issues (i.e. comment which appears to reference comment) seems to indicate that access takes priority over kind:
class X {
public:
void f();
int i;
private:
void g();
int j;
};
At the same time, NL.16 was updated with the goal of clarifying, adding the text:
Sometimes, the default order of members conflicts with a desire to separate the public interface from implementation details. In such cases, private types and functions can be placed with private data.
Here, it's stated that "a desire to separate the public interface from implementation details" (i.e. grouping every kind of public member together, as in the above snippet) is in conflict with "the default order of members." This seems to indicate that this is not the default, which would mean that the default order of members is instead to prioritize kind over access:
class X {
public:
void f();
private:
void g();
public:
int i;
private:
int j;
};
So, the guideline as written does not clearly explain which dimension takes priority, and searching through the repository history shows that when this came up previously, there were two simultaneous but contradictory resolutions.
Suggestion: Provide one of the two above snippets as an unambiguous example of NL.16 showing the preferred first choice (when you have no constraints or better ideas).
- Lingua principale
- CSS
- Stelle
- 45.5k
- Fork
- 5.6k
- Merge medio
- 6m
- PR unite (30g)
- 1
Preparare l'ambiente
- 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 isocpp/CppCoreGuidelines
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
isocpp/CppCoreGuidelines#2345 ·
-
Use short #s-xxx as ref, not long like #sl-the-standard-library or #gsl-guidelines-support-libraryAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
isocpp/CppCoreGuidelines#2340 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
isocpp/CppCoreGuidelines#2205 · 8 commenti ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 64/100
isocpp/CppCoreGuidelines#1649 · 3 commenti ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
isocpp/CppCoreGuidelines#2342 · 2 commenti ·
Tutte le issue di isocpp/CppCoreGuidelines
Issue simili
-
Feature Request
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
spotDL/spotify-downloader#2839 ·
I maintainer di solito rispondono entro 1 giorno
-
Missing license fileAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 83/100
gofish-graphics/gofish-graphics#1384 ·
I maintainer di solito rispondono entro 1 giorno
-
seed-request
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 68/100
camp-registry/camp-index#777 ·
I maintainer di solito rispondono entro 1 giorno
-
Add Text to History PageApertaPROJECT: website-redesign volunteers
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
thewca/worldcubeassociation.org#16616 ·
I maintainer di solito rispondono entro 1 giorno