Skip to content

Commit 43bbde7

Browse files
committed
Committing PR #1640 to main branch
1 parent ac7079b commit 43bbde7

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

CppCoreGuidelines.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# <a name="main"></a>C++ Core Guidelines
22

3-
May 28, 2020
3+
July 3, 2020
44

55

66
Editors:
@@ -314,7 +314,7 @@ The rules are not value-neutral.
314314
They are meant to make code simpler and more correct/safer than most existing C++ code, without loss of performance.
315315
They are meant to inhibit perfectly valid C++ code that correlates with errors, spurious complexity, and poor performance.
316316

317-
The rules are not precise to the point where a person (or machine) can follow them blindly.
317+
The rules are not precise to the point where a person (or machine) can follow them without thinking.
318318
The enforcement parts try to be that, but we would rather leave a rule or a definition a bit vague
319319
and open to interpretation than specify something precisely and wrong.
320320
Sometimes, precision comes only with time and experience.
@@ -352,7 +352,7 @@ We try to resolve those using tools.
352352
Each rule has an **Enforcement** section listing ideas for enforcement.
353353
Enforcement might be done by code review, by static analysis, by compiler, or by run-time checks.
354354
Wherever possible, we prefer "mechanical" checking (humans are slow, inaccurate, and bore easily) and static checking.
355-
Run-time checks are suggested only rarely where no alternative exists; we do not want to introduce "distributed fat".
355+
Run-time checks are suggested only rarely where no alternative exists; we do not want to introduce "distributed bloat".
356356
Where appropriate, we label a rule (in the **Enforcement** sections) with the name of groups of related rules (called "profiles").
357357
A rule can be part of several profiles, or none.
358358
For a start, we have a few profiles corresponding to common needs (desires, ideals):
@@ -4724,7 +4724,7 @@ These operations disagree about copy semantics. This will lead to confusion and
47244724

47254725
## <a name="SS-dtor"></a>C.dtor: Destructors
47264726

4727-
"Does this class need a destructor?" is a surprisingly powerful design question.
4727+
"Does this class need a destructor?" is a surprisingly insightful design question.
47284728
For most classes the answer is "no" either because the class holds no resources or because destruction is handled by [the rule of zero](#Rc-zero);
47294729
that is, its members can take care of themselves as concerns destruction.
47304730
If the answer is "yes", much of the design of the class follows (see [the rule of five](#Rc-five)).
@@ -5561,7 +5561,7 @@ Makes it explicit that the same value is expected to be used in all constructors
55615561
// ...
55625562
};
55635563

5564-
How would a maintainer know whether `j` was deliberately uninitialized (probably a poor idea anyway) and whether it was intentional to give `s` the default value `""` in one case and `qqq` in another (almost certainly a bug)? The problem with `j` (forgetting to initialize a member) often happens when a new member is added to an existing class.
5564+
How would a maintainer know whether `j` was deliberately uninitialized (probably a bad idea anyway) and whether it was intentional to give `s` the default value `""` in one case and `qqq` in another (almost certainly a bug)? The problem with `j` (forgetting to initialize a member) often happens when a new member is added to an existing class.
55655565

55665566
##### Example
55675567

@@ -6710,7 +6710,7 @@ In particular, ensure that an object compares equal to its copy.
67106710
{
67116711
Sorted_vector<string> v2 {v};
67126712
if (v != v2)
6713-
cout << "insanity rules!\n";
6713+
cout << "Behavior against reason and logic.\n";
67146714
// ...
67156715
}
67166716

@@ -8720,7 +8720,7 @@ but at least we can see that something tricky is going on.
87208720
##### Note
87218721

87228722
Unfortunately, `union`s are commonly used for type punning.
8723-
We don't consider "sometimes, it works as expected" a strong argument.
8723+
We don't consider "sometimes, it works as expected" a conclusive argument.
87248724

87258725
C++17 introduced a distinct type `std::byte` to facilitate operations on raw object representation. Use that type instead of `unsigned char` or `char` for these operations.
87268726

@@ -10688,7 +10688,7 @@ Readability. Limit the scope in which a variable can be used. Don't risk used-be
1068810688

1068910689
##### Example, bad
1069010690

10691-
SomeLargeType var;
10691+
SomeLargeType var; // Hard-to-read CaMeLcAsEvArIaBlE
1069210692

1069310693
if (cond) // some non-trivial condition
1069410694
Set(&var);
@@ -13433,7 +13433,7 @@ Alternatives for users
1343313433
This section contains rules for people who need high performance or low-latency.
1343413434
That is, these are rules that relate to how to use as little time and as few resources as possible to achieve a task in a predictably short time.
1343513435
The rules in this section are more restrictive and intrusive than what is needed for many (most) applications.
13436-
Do not blindly try to follow them in general code: achieving the goals of low latency requires extra work.
13436+
Do not naïvely try to follow them in general code: achieving the goals of low latency requires extra work.
1343713437

1343813438
Performance rule summary:
1343913439

@@ -14707,7 +14707,7 @@ Thread creation is expensive.
1470714707
// process
1470814708
}
1470914709

14710-
void master(istream& is)
14710+
void dispatcher(istream& is)
1471114711
{
1471214712
for (Message m; is >> m; )
1471314713
run_list.push_back(new thread(worker, m));
@@ -14719,7 +14719,7 @@ Instead, we could have a set of pre-created worker threads processing the messag
1471914719

1472014720
Sync_queue<Message> work;
1472114721

14722-
void master(istream& is)
14722+
void dispatcher(istream& is)
1472314723
{
1472414724
for (Message m; is >> m; )
1472514725
work.put(m);
@@ -18126,7 +18126,7 @@ Templating a class hierarchy that has many functions, especially many virtual fu
1812618126
Vector<int> vi;
1812718127
Vector<string> vs;
1812818128

18129-
It is probably a dumb idea to define a `sort` as a member function of a container, but it is not unheard of and it makes a good example of what not to do.
18129+
It is probably a bad idea to define a `sort` as a member function of a container, but it is not unheard of and it makes a good example of what not to do.
1813018130

1813118131
Given this, the compiler cannot know if `vector<int>::sort()` is called, so it must generate code for it.
1813218132
Similar for `vector<string>::sort()`.
@@ -20107,7 +20107,7 @@ However, in the context of the styles of programming we recommend and support wi
2010720107

2010820108
Even today, there can be contexts where the rules make sense.
2010920109
For example, lack of suitable tool support can make exceptions unsuitable in hard-real-time systems,
20110-
but please don't blindly trust "common wisdom" (e.g., unsupported statements about "efficiency");
20110+
but please don't naïvely trust "common wisdom" (e.g., unsupported statements about "efficiency");
2011120111
such "wisdom" may be based on decades-old information or experienced from languages with very different properties than C++
2011220112
(e.g., C or Java).
2011320113

@@ -21945,7 +21945,7 @@ Never allow an error to be reported from a destructor, a resource deallocation f
2194521945

2194621946
Here, copying `s` could throw, and if that throws and if `n`'s destructor then also throws, the program will exit via `std::terminate` because two exceptions can't be propagated simultaneously.
2194721947

21948-
2. Classes with `Nefarious` members or bases are also hard to use safely, because their destructors must invoke `Nefarious`' destructor, and are similarly poisoned by its poor behavior:
21948+
2. Classes with `Nefarious` members or bases are also hard to use safely, because their destructors must invoke `Nefarious`' destructor, and are similarly poisoned by its bad behavior:
2194921949

2195021950

2195121951
class Innocent_bystander {
@@ -21955,7 +21955,7 @@ Never allow an error to be reported from a destructor, a resource deallocation f
2195521955

2195621956
void test(string& s)
2195721957
{
21958-
Innocent_bystander i; // more trouble brewing
21958+
Innocent_bystander i; // more trouble brewing
2195921959
string copy2 = s; // copy the string
2196021960
} // destroy copy and then i
2196121961

0 commit comments

Comments
 (0)