diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index d5bcaea..2de50c7 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -8484,7 +8484,7 @@ Convenience of use and avoidance of errors. { return d = (d == Day::sun) ? Day::mon : static_cast(static_cast(d)+1); } - + Day today = Day::sat; Day tomorrow = ++today; @@ -11247,7 +11247,7 @@ Surprised? I'm just glad I didn't crash the program. ##### Note -Programmers who write casts typically assume that they know what they are doing, +Programmers who write casts typically assume that they know what they are doing, or that writing a cast makes the program "easier to read". In fact, they often disable the general rules for using values. Overload resolution and template instantiation usually pick the right function if there is a right function to pick. @@ -12550,7 +12550,7 @@ It has been noted that is a common beginners error. If you use C-style strings, you must know the `` functions well. -Being verbose and writing +Being verbose and writing if(strcmp(p1, p2) != 0) { ... } // are the two C-style strings equal? (mistake!) @@ -19932,9 +19932,9 @@ An implementation of this profile shall recognize the following patterns in sour Type safety profile summary: -* Type.1: [Avoid casts](#Res-casts): -a. Don't use `reinterpret_cast`; A strict version of [Avoid casts](#Res-casts) and [prefer named casts](#Res-casts-named). -b. Don't use `static_cast` for arithmetic types; A strict version of [Avoid casts](#Res-casts) and [prefer named casts](#Res-casts-named). +* Type.1: [Avoid casts](#Res-casts): +a. Don't use `reinterpret_cast`; A strict version of [Avoid casts](#Res-casts) and [prefer named casts](#Res-casts-named). +b. Don't use `static_cast` for arithmetic types; A strict version of [Avoid casts](#Res-casts) and [prefer named casts](#Res-casts-named). c. Don't cast between pointer types where the source type and the target type are the same; A strict version of [Avoid casts](#Res-casts). d. Don't cast between pointer types when the conversion could be implicit; A strict version of [Avoid casts](#Res-casts). * Type.2: Don't use `static_cast` to downcast: @@ -21498,7 +21498,7 @@ Clang-tidy has a set of rules that specifically enforce the C++ Core Guidelines. ### Tools: [CppCoreCheck](https://docs.microsoft.com/en-us/visualstudio/code-quality/using-the-cpp-core-guidelines-checkers) -The Microsoft compiler's C++ code analysis contains a set of rules specifically aimed at enforcement of the C++ Core Guidelines. +The Microsoft compiler's C++ code analysis contains a set of rules specifically aimed at enforcement of the C++ Core Guidelines. # Glossary