Skip to content

Commit 83de05d

Browse files
committed
Several minor improvements
Fixed some typos, added some links and some further minor improvements
1 parent 7ce6cea commit 83de05d

5 files changed

+13
-14
lines changed

03-Style.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ Header files must contain a distinctly-named include guard to avoid problems wit
139139
#define MYPROJECT_MYCLASS_HPP
140140

141141
namespace MyProject {
142-
class MyClass {
143-
};
142+
class MyClass {
143+
};
144144
}
145145

146146
#endif
@@ -274,7 +274,7 @@ There is almost never a reason to declare an identifier in the global namespaces
274274

275275
## Use the Correct Integer Type For stdlib Features
276276

277-
The standard library generally returns `size_t` for anything related to size. What exactly `size_t` is is implementation defined.
277+
The standard library generally returns `size_t` for anything related to size. What exactly `size_t` is, is implementation defined.
278278

279279
In general, using `auto` will avoid most of these issues, but not all.
280280

@@ -312,10 +312,10 @@ However, you can easily create unreadable expressions using too much or wrong op
312312
313313
More detailed, you should keep these things in mind:
314314
315-
* Overloading `operator=` when handling with resources is a must, see "Consider the Rule of Zero" below.
315+
* Overloading `operator=` when handling with resources is a must, see [Consider the Rule of Zero](03-Style.md#consider-the-rule-of-zero) below.
316316
* For all other operators, only overload them when they are used in a context that is commonly connected to these operators. Typical scenarios are concatenating things with +, negating expressions that can be considered "true" or "false", etc.
317317
* Always be aware of the [operator precedence](http://en.cppreference.com/w/cpp/language/operator_precedence) and try to circumvent unintuitive constructs.
318-
* Do not overload exotic operators such as ~ or %.
318+
* Do not overload exotic operators such as ~ or %.
319319
* [Never](http://stackoverflow.com/questions/5602112/when-to-overload-the-comma-operator?answertab=votes#tab-top) overload `operator ,` (the comma operator).
320320
* Use `operator >>` and `operator <<` when dealing with streams. For example, you can overload `operator <<(std::ostream &, MyClass const &)` to enable "writing" you class into a stream, such as std::cout or an std::fstream or std::stringstream. The latter is often used to create a textual representation of a value.
321321
* There are more common operators to overload [described here](http://stackoverflow.com/questions/4421706/operator-overloading?answertab=votes#tab-top)
@@ -332,7 +332,7 @@ Instead mark single parameter constructors as `explicit`, which requires them to
332332
333333
### Conversion Operators
334334
335-
Similarly to single parameter constructors, conversion operators can be called by the compiler and introduce unexpected overhead. The should also be marked as `explicit`.
335+
Similarly to single parameter constructors, conversion operators can be called by the compiler and introduce unexpected overhead. They should also be marked as `explicit`.
336336
337337
338338
## Consider the Rule of Zero

04-Considering_Safety.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public:
2121

2222
private:
2323
std::string m_value;
24-
}
24+
};
2525

2626

2727
// Good Idea
@@ -40,7 +40,7 @@ public:
4040

4141
private:
4242
std::string m_value;
43-
}
43+
};
4444
```
4545
4646
### Consider Return By Value for Mutable Data, `const &` for Immutable
@@ -68,7 +68,6 @@ auto mybuffer = std::make_unique<char[]>(length); // C++14
6868
auto mybuffer = std::unique_ptr<char[]>(new char[length]); // C++11
6969
7070
// or for reference counted objects
71-
7271
auto myobj = std::make_shared<MyClass>();
7372
7473
// ...
@@ -88,7 +87,7 @@ Exceptions cannot be ignored. Return values, such as using `boost::optional`, ca
8887
Stroustrup, the original designer of C++, [makes this point](http://www.stroustrup.com/bs_faq2.html#exceptions-why) much better than I ever could.
8988

9089
## Use C++-style cast instead of C-style cast
91-
Use the C++-style cast(static\_cast<>, dynamic\_cast<> ...) instead of the C-style cast. The C++-style cast allows more compiler checks and is considerable safer.
90+
Use the C++-style cast (static\_cast<>, dynamic\_cast<> ...) instead of the C-style cast. The C++-style cast allows more compiler checks and is considerable safer.
9291

9392
```cpp
9493
// Bad Idea
@@ -98,7 +97,7 @@ int i = (int) x;
9897
// Good Idea
9998
int i = static_cast<int>(x);
10099
```
101-
Additionaly the C++ cast style is more visible and has the possiblity to search for.
100+
Additionally the C++ cast style is more visible and has the possibility to search for.
102101

103102
## Additional Resources
104103

05-Considering_Maintainability.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace my_project {
1717
// static const double 3.14159 = 3.14159;
1818
// which leads to a compile-time error. Sometimes such errors are hard to understand.
1919
static const double PI = 3.14159;
20-
}
20+
};
2121
}
2222
```
2323

07-Considering_Threadability.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Besides being global data, statics are not always constructed and deconstructed
1414

1515
### Singletons
1616

17-
A singleton is often implemented with a static and/or `shared_ptr`
17+
A singleton is often implemented with a static and/or `shared_ptr`.
1818

1919
## Avoid Heap Operations
2020

10-Further_Reading.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
* https://svn.boost.org/trac/boost/wiki/BestPracticeHandbook - Best Practice Handbook from Nial Douglas
99
* http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=ListOfChecks
1010
* http://emptycrate.com/
11-
* http://stackoverflow.com/questions/tagged/c%2b%2b-faq?sort=votes&pageSize=15 StackOverflow C++ FAQ
11+
* http://stackoverflow.com/questions/tagged/c%2b%2b-faq?sort=votes&pageSize=15 - StackOverflow C++ FAQ

0 commit comments

Comments
 (0)