From b8254dcf96873c9f2d0012c7cc960fddb755d8bb Mon Sep 17 00:00:00 2001 From: Thibault Kruse Date: Sat, 3 Oct 2015 13:14:52 +0200 Subject: [PATCH 1/3] fix mix of tabs and spaces --- CppCoreGuidelines.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index e9a39cd..cdc1c21 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -5297,17 +5297,17 @@ Note that because of language rules, the covariant return type cannot be a smart public: point(int xx, int yy) : x{xx}, y{yy} { } int get_x() { return x; } - void set_x(int xx) { x = xx; } + void set_x(int xx) { x = xx; } int get_y() { return y; } - void set_y(int yy) { y = yy; } - // no behavioral member functions + void set_y(int yy) { y = yy; } + // no behavioral member functions }; Consider making such a class a `struct` -- that is, a behaviorless bunch of variables, all public data and no member functions. struct point { - int x = 0; - int y = 0; + int x = 0; + int y = 0; }; ##### Note @@ -8695,12 +8695,12 @@ make the job of the optimizer much harder. Simple code often optimizes better th ##### Example int matrix[rows][cols]; - + //bad for(int c=0; c p = D::Create(); // creating a D object + shared_ptr p = D::Create(); // creating a D object This design requires the following discipline: @@ -13246,7 +13246,7 @@ Most compilers already warn about simple cases and has the information to do mor { return ...; } - + auto v = get_large_vector(); //return by value is ok, most modern compilers will do copy elision ##### Example From 572f9c6cbf137f350c01e39af5eec4807c682846 Mon Sep 17 00:00:00 2001 From: Thibault Kruse Date: Sat, 3 Oct 2015 10:39:07 +0200 Subject: [PATCH 2/3] ??? for placeholder --- CppCoreGuidelines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index cdc1c21..7cba91a 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -11924,7 +11924,7 @@ For the purposes of this document, bounds-safety is defined to be the property t The following are under consideration but not yet in the rules below, and may be better in other profiles: - - +* ??? An implementation of this profile shall recognize the following patterns in source code as non-conforming and issue a diagnostic. From 806e40b21413d3f91571409f2f412942252cfabc Mon Sep 17 00:00:00 2001 From: Thibault Kruse Date: Sat, 3 Oct 2015 13:36:46 +0200 Subject: [PATCH 3/3] missing indent --- CppCoreGuidelines.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 7cba91a..2f03d5d 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -12981,8 +12981,7 @@ Here, if constructing `copy2` throws, we have the same problem because `i`'s des void test() { std::array arr; // this line can std::terminate(!) - -} + } The behavior of arrays is undefined in the presence of destructors that throw because there is no reasonable rollback behavior that could ever be devised. Just think: What code can the compiler generate for constructing an `arr` where, if the fourth object's constructor throws, the code has to give up and in its cleanup mode tries to call the destructors of the already-constructed objects... and one or more of those destructors throws? There is no satisfactory answer.