From d1f5b4c4555af51e06f879386f9d34b29f438fba Mon Sep 17 00:00:00 2001 From: Andrew Pardoe Date: Mon, 27 Nov 2017 12:04:22 -0800 Subject: [PATCH] layout tag --- CppCoreGuidelines.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index b994f49..573b9d0 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -1,3 +1,7 @@ +--- +layout: default +--- + # C++ Core Guidelines November 27, 2017 @@ -5142,7 +5146,7 @@ A class with members that all have default constructors implicitly gets a defaul vector v; }; - X x; // means X{{}, {}}; that is the empty string and the empty vector + X x; // means X{{ "{{" }}}, {}}; that is the empty string and the empty vector Beware that built-in types are not properly default constructed: @@ -7586,7 +7590,7 @@ Subscripting the resulting base pointer will lead to invalid object access and p void use(B*); - D a[] = {{1, 2}, {3, 4}, {5, 6}}; + D a[] = {{ "{{" }}1, 2}, {3, 4}, {5, 6}}; B* p = a; // bad: a decays to &a[0] which is converted to a B* p[1].x = 7; // overwrite D[0].y @@ -11645,7 +11649,7 @@ In the rare cases where the slicing was deliberate the code can be surprising. class Shape { /* ... */ }; class Circle : public Shape { /* ... */ Point c; int r; }; - Circle c {{0, 0}, 42}; + Circle c {{ "{{" }}0, 0}, 42}; Shape s {c}; // copy Shape part of Circle The result will be meaningless because the center and radius will not be copied from `c` into `s`. @@ -14623,7 +14627,7 @@ To make error handling systematic, robust, and non-repetitive. void use() { - Foo bar {{Thing{1}, Thing{2}, Thing{monkey}}, {"my_file", "r"}, "Here we go!"}; + Foo bar {{ "{{" }}Thing{1}, Thing{2}, Thing{monkey}}, {"my_file", "r"}, "Here we go!"}; // ... }