From 314cff005ceaaade11cb4f1a8541348b0835aeb2 Mon Sep 17 00:00:00 2001 From: Thibault Kruse Date: Tue, 29 Sep 2015 17:57:48 +0200 Subject: [PATCH] Fix code snippets that do not compile, or mark them with at least one ??? --- CppCoreGuidelines.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 5942fed..ca0182b 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -7157,16 +7157,16 @@ Some of these expressions are unconditionally bad (e.g., they rely on undefined **Example**: - x=k*y+z; // OK + x=k*y+z; // OK - auto t1 = k*y; // bad: unnecessarily verbose + auto t1 = k*y; // bad: unnecessarily verbose x = t1+z; - if(0<=x && x av = arr; @@ -10784,7 +10784,7 @@ Dynamic accesses into arrays are difficult for both tools and humans to validate } // ALTERNATIVE B: Use at() for access - void f() + void f2() { int arr[COUNT]; for (int i = 0; i < COUNT; ++i) @@ -11152,25 +11152,25 @@ Choose a "house style", but leave "imported" libraries with their original style **Example**, ISO Standard, use lower case only and digits, separate words with underscores: - int - vector - my_map +* `int` +* `vector` +* `my_map` Avoid double underscores `__` **Example**: [Stroustrup](http://www.stroustrup.com/Programming/PPP-style.pdf): ISO Standard, but with upper case used for your own types and concepts: - int - vector - My_map +* `int` +* `vector` +* `My_map` **Example**: CamelCase: capitalize each word in a multi-word identifier - int - vector - MyMap - myMap +* `int` +* `vector` +* `MyMap` +* `myMap` Some conventions capitalize the first letter, some don't. @@ -11933,11 +11933,11 @@ The `string`s of `v` are destroyed upon exit from `bad()` and so is `v` itself. **Example**: - vector + ??? vector **Example**: - factory + ??? factory **Enforcement**: Check for pointers and references returned from functions and see if they are assigned to resource handles (e.g., to a `unique_ptr`).