Skip to content

Commit 1936cb6

Browse files
authored
[NL.{11,15}] Bring rules in order (isocpp#1629)
The rules NL.11 (Make literals readable) and NL.15 (Use spaces sparingly) are placed in inverted order in the text flow, swap them.
1 parent 4625c98 commit 1936cb6

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

CppCoreGuidelines.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21298,6 +21298,38 @@ ISO Standard, but with upper case used for your own types and concepts:
2129821298

2129921299
Impossible.
2130021300

21301+
### <a name="Rl-literals"></a>NL.11: Make literals readable
21302+
21303+
##### Reason
21304+
21305+
Readability.
21306+
21307+
##### Example
21308+
21309+
Use digit separators to avoid long strings of digits
21310+
21311+
auto c = 299'792'458; // m/s2
21312+
auto q2 = 0b0000'1111'0000'0000;
21313+
auto ss_number = 123'456'7890;
21314+
21315+
##### Example
21316+
21317+
Use literal suffixes where clarification is needed
21318+
21319+
auto hello = "Hello!"s; // a std::string
21320+
auto world = "world"; // a C-style string
21321+
auto interval = 100ms; // using <chrono>
21322+
21323+
##### Note
21324+
21325+
Literals should not be sprinkled all over the code as ["magic constants"](#Res-magic),
21326+
but it is still a good idea to make them readable where they are defined.
21327+
It is easy to make a typo in a long string of integers.
21328+
21329+
##### Enforcement
21330+
21331+
Flag long digit sequences. The trouble is to define "long"; maybe 7.
21332+
2130121333
### <a name="Rl-space"></a>NL.15: Use spaces sparingly
2130221334

2130321335
##### Reason
@@ -21333,38 +21365,6 @@ This rule was added after many requests for guidance.
2133321365

2133421366
We value well-placed whitespace as a significant help for readability. Just don't overdo it.
2133521367

21336-
### <a name="Rl-literals"></a>NL.11: Make literals readable
21337-
21338-
##### Reason
21339-
21340-
Readability.
21341-
21342-
##### Example
21343-
21344-
Use digit separators to avoid long strings of digits
21345-
21346-
auto c = 299'792'458; // m/s2
21347-
auto q2 = 0b0000'1111'0000'0000;
21348-
auto ss_number = 123'456'7890;
21349-
21350-
##### Example
21351-
21352-
Use literal suffixes where clarification is needed
21353-
21354-
auto hello = "Hello!"s; // a std::string
21355-
auto world = "world"; // a C-style string
21356-
auto interval = 100ms; // using <chrono>
21357-
21358-
##### Note
21359-
21360-
Literals should not be sprinkled all over the code as ["magic constants"](#Res-magic),
21361-
but it is still a good idea to make them readable where they are defined.
21362-
It is easy to make a typo in a long string of integers.
21363-
21364-
##### Enforcement
21365-
21366-
Flag long digit sequences. The trouble is to define "long"; maybe 7.
21367-
2136821368
### <a name="Rl-order"></a>NL.16: Use a conventional class member declaration order
2136921369

2137021370
##### Reason

0 commit comments

Comments
 (0)