resolving #1238 about style

The caveat is added only to the subset of rules where it appears to be
relevant
This commit is contained in:
Bjarne Stroustrup 2018-09-03 10:20:20 -04:00
parent dd4cae0260
commit c11001f0a6

View File

@ -3613,7 +3613,7 @@ A returned rvalue reference goes out of scope at the end of the full expression
This kind of use is a frequent source of bugs, often incorrectly reported as a compiler bug. This kind of use is a frequent source of bugs, often incorrectly reported as a compiler bug.
An implementer of a function should avoid setting such traps for users. An implementer of a function should avoid setting such traps for users.
The [lifetipe safety profile](#SS-lifetime) will (when completely implemented) catch such problems The [lifetipe safety profile](#SS-lifetime) will (when completely implemented) catch such problems.
##### Example ##### Example
@ -20232,7 +20232,7 @@ Consistent naming and layout are helpful.
If for no other reason because it minimizes "my style is better than your style" arguments. If for no other reason because it minimizes "my style is better than your style" arguments.
However, there are many, many, different styles around and people are passionate about them (pro and con). However, there are many, many, different styles around and people are passionate about them (pro and con).
Also, most real-world projects includes code from many sources, so standardizing on a single style for all code is often impossible. Also, most real-world projects includes code from many sources, so standardizing on a single style for all code is often impossible.
We present a set of rules that you might use if you have no better ideas, but the real aim is consistency, rather than any particular rule set. After many requests for guidance from users, we present a set of rules that you might use if you have no better ideas, but the real aim is consistency, rather than any particular rule set.
IDEs and tools can help (as well as hinder). IDEs and tools can help (as well as hinder).
Naming and layout rules: Naming and layout rules:
@ -20531,6 +20531,9 @@ This rule is a default to use only if you have a choice.
Often, you don't have a choice and must follow an established style for [consistency](#Rl-name). Often, you don't have a choice and must follow an established style for [consistency](#Rl-name).
The need for consistency beats personal taste. The need for consistency beats personal taste.
This is a recommendation for [when you have no constraints or better ideas](#S-naming).
Thus rule was added after many requests for guidance.
##### Example ##### Example
[Stroustrup](http://www.stroustrup.com/Programming/PPP-style.pdf): [Stroustrup](http://www.stroustrup.com/Programming/PPP-style.pdf):
@ -20572,6 +20575,9 @@ Too much space makes the text larger and distracts.
Some IDEs have their own opinions and add distracting space. Some IDEs have their own opinions and add distracting space.
This is a recommendation for [when you have no constraints or better ideas](#S-naming).
Thus rule was added after many requests for guidance.
##### Note ##### Note
We value well-placed whitespace as a significant help for readability. Just don't overdo it. We value well-placed whitespace as a significant help for readability. Just don't overdo it.
@ -20623,6 +20629,9 @@ When declaring a class use the following order
Use the `public` before `protected` before `private` order. Use the `public` before `protected` before `private` order.
This is a recommendation for [when you have no constraints or better ideas](#S-naming).
Thus rule was added after many requests for guidance.
##### Example ##### Example
class X { class X {
@ -20677,6 +20686,9 @@ This is the original C and C++ layout. It preserves vertical space well. It dist
In the context of C++, this style is often called "Stroustrup". In the context of C++, this style is often called "Stroustrup".
This is a recommendation for [when you have no constraints or better ideas](#S-naming).
Thus rule was added after many requests for guidance.
##### Example ##### Example
struct Cable { struct Cable {
@ -20748,6 +20760,11 @@ The use in expressions argument doesn't hold for references.
T &operator[](size_t); // just strange T &operator[](size_t); // just strange
T & operator[](size_t); // undecided T & operator[](size_t); // undecided
##### Note
This is a recommendation for [when you have no constraints or better ideas](#S-naming).
Thus rule was added after many requests for guidance.
##### Enforcement ##### Enforcement
Impossible in the face of history. Impossible in the face of history.
@ -20844,6 +20861,9 @@ but they also confuse more people, especially novices relying on teaching materi
As ever, remember that the aim of these naming and layout rules is consistency and that aesthetics vary immensely. As ever, remember that the aim of these naming and layout rules is consistency and that aesthetics vary immensely.
This is a recommendation for [when you have no constraints or better ideas](#S-naming).
Thus rule was added after many requests for guidance.
##### Enforcement ##### Enforcement
Flag `const` used as a suffix for a type. Flag `const` used as a suffix for a type.