testing backticks-cpp

This commit is contained in:
Sergey Zubkov
2020-08-03 16:53:17 -04:00
parent f202e94c4e
commit e023c0775b

View File

@@ -484,12 +484,14 @@ What is expressed in code has defined semantics and can (in principle) be checke
##### Example ##### Example
class Date { ```cpp
public: class Date {
Month month() const; // do public:
int month(); // don't 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 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. 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`: This loop is a restricted form of `std::find`:
void f(vector<string>& v) ```cpp
{ void f(vector<string>& v)
string val; {
cin >> val; string val;
// ... cin >> val;
int index = -1; // bad, plus should use gsl::index // ...
for (int i = 0; i < v.size(); ++i) { int index = -1; // bad, plus should use gsl::index
if (v[i] == val) { for (int i = 0; i < v.size(); ++i) {
index = i; if (v[i] == val) {
break; index = i;
} break;
} }
// ...
} }
// ...
}
```
##### Example, good ##### Example, good