From e023c0775ba86457bd10a63ecfa52378797b1e79 Mon Sep 17 00:00:00 2001 From: Sergey Zubkov Date: Mon, 3 Aug 2020 16:53:17 -0400 Subject: [PATCH] testing backticks-cpp --- CppCoreGuidelines.md | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 8a75cd2..137ead8 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -484,12 +484,14 @@ What is expressed in code has defined semantics and can (in principle) be checke ##### Example - class Date { - public: - Month month() const; // do - int month(); // don't - // ... - }; +```cpp +class Date { +public: + Month month() const; // do + int month(); // don't + // ... +}; +``` The first declaration of `month` is explicit about returning a `Month` and about not modifying the state of the `Date` object. The second version leaves the reader guessing and opens more possibilities for uncaught bugs. @@ -498,20 +500,22 @@ The second version leaves the reader guessing and opens more possibilities for u This loop is a restricted form of `std::find`: - void f(vector& v) - { - string val; - cin >> val; - // ... - int index = -1; // bad, plus should use gsl::index - for (int i = 0; i < v.size(); ++i) { - if (v[i] == val) { - index = i; - break; - } +```cpp +void f(vector& v) +{ + string val; + cin >> val; + // ... + int index = -1; // bad, plus should use gsl::index + for (int i = 0; i < v.size(); ++i) { + if (v[i] == val) { + index = i; + break; } - // ... } + // ... +} +``` ##### Example, good