You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 02-Use_the_Tools_Available.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ Use an industry standard widely accepted build tool. This prevents you from rein
33
33
*[maiken](https://github.com/Dekken/maiken) - Crossplatform build tool with Maven-esque configuration style.
34
34
*[Qt Build Suite](http://doc.qt.io/qbs/) - Crossplatform build tool From Qt.
35
35
*[meson](http://mesonbuild.com/index.html) - Open source build system meant to be both extremely fast, and, even more importantly, as user friendly as possible.
36
-
*[premake](https://premake.github.io/)
36
+
*[premake](https://premake.github.io/)
37
37
*[xmake](https://xmake.io) - A cross-platform build utility based on Lua. Modern C/C++ build tools, Support multi-language hybrid compilation
38
38
39
39
Remember, it's not just a build tool, it's also a programming language. Try to maintain good clean build scripts and follow the recommended practices for the tool you are using.
*[Memoro](https://epfl-vlsc.github.io/memoro/) - A detailed heap profiler
343
+
*[Memoro](https://epfl-vlsc.github.io/memoro/) - A detailed heap profiler
344
344
345
345
## Ignoring Warnings
346
346
@@ -410,6 +410,6 @@ Don't forget to make sure that your error handling is being tested and works pro
410
410
411
411
[pahole](https://linux.die.net/man/1/pahole) generates data on holes in the packing of data structures and classes in compiled code. It can also the size of structures and how they fit within the system's cache lines.
412
412
413
-
### BinSkim
413
+
### BinSkim
414
414
415
-
[BinSkim](https://github.com/Microsoft/binskim) is a binary static analysis tool that provides security and correctness results for Windows Portable Executable and *nix ELF binary formats
415
+
[BinSkim](https://github.com/Microsoft/binskim) is a binary static analysis tool that provides security and correctness results for Windows Portable Executable and *nix ELF binary formats
Copy file name to clipboardExpand all lines: 03-Style.md
+3-4
Original file line number
Diff line number
Diff line change
@@ -240,7 +240,7 @@ It also makes it possible to have two separate files next to each other on one s
240
240
```
241
241
242
242
## Initialize Member Variables
243
-
...with the member initializer list.
243
+
...with the member initializer list.
244
244
245
245
For POD types, the performance of an initializer list is the same as manual initialization, but for other types there is a clear performance gain, see below.
246
246
@@ -288,8 +288,8 @@ private:
288
288
};
289
289
290
290
// Good Idea
291
-
// The default constructor for m_myOtherClass is never called here, so
292
-
// there is a performance gain if MyOtherClass is not is_trivially_default_constructible.
291
+
// The default constructor for m_myOtherClass is never called here, so
292
+
// there is a performance gain if MyOtherClass is not is_trivially_default_constructible.
293
293
class MyClass
294
294
{
295
295
public:
@@ -454,4 +454,3 @@ The Rule of Zero states that you do not provide any of the functions that the co
454
454
The goal is to let the compiler provide optimal versions that are automatically maintained when more member variables are added.
455
455
456
456
[This article](http://www.nirfriedman.com/2015/06/27/cpp-rule-of-zero/) provides a background and explains techniques for implementing nearly 100% of the time.
### Do not pass and return simple types by const ref
39
+
### Do not pass and return simple types by const ref
40
40
41
41
```cpp
42
42
// Very Bad Idea
@@ -47,7 +47,7 @@ public:
47
47
: m_int_value(t_int_value)
48
48
{
49
49
}
50
-
50
+
51
51
const int& get_int_value() const
52
52
{
53
53
return m_int_value;
@@ -69,7 +69,7 @@ public:
69
69
: m_int_value(t_int_value)
70
70
{
71
71
}
72
-
72
+
73
73
int get_int_value() const
74
74
{
75
75
return m_int_value;
@@ -101,7 +101,7 @@ auto mybuffer = std::make_unique<char[]>(length); // C++14
101
101
auto mybuffer = std::unique_ptr<char[]>(newchar[length]); // C++11
102
102
103
103
// or for reference counted objects
104
-
auto myobj = std::make_shared<MyClass>();
104
+
auto myobj = std::make_shared<MyClass>();
105
105
106
106
// ...
107
107
// myobj is automatically freed for you whenever it is no longer used.
@@ -111,7 +111,7 @@ auto myobj = std::make_shared<MyClass>();
111
111
112
112
Both of these guarantee contiguous memory layout of objects and can (and should) completely replace your usage of C-style arrays for many of the reasons listed for not using bare pointers.
113
113
114
-
Also, [avoid](http://stackoverflow.com/questions/3266443/can-you-use-a-shared-ptr-for-raii-of-c-style-arrays) using `std::shared_ptr` to hold an array.
114
+
Also, [avoid](http://stackoverflow.com/questions/3266443/can-you-use-a-shared-ptr-for-raii-of-c-style-arrays) using `std::shared_ptr` to hold an array.
Copy file name to clipboardExpand all lines: 08-Considering_Performance.md
+4-5
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ For more examples see [this article](http://blog2.emptycrate.com/content/templat
43
43
44
44
### Avoid Recursive Template Instantiations
45
45
46
-
Recursive template instantiations can result in a significant load on the compiler and more difficult to understand code.
46
+
Recursive template instantiations can result in a significant load on the compiler and more difficult to understand code.
47
47
48
48
[Consider using variadic expansions and folds when possible instead.](http://articles.emptycrate.com/2016/05/14/folds_in_cpp11_ish.html)
49
49
@@ -289,11 +289,11 @@ if (MyObject obj(index); obj.good()) {
289
289
290
290
### Prefer `double` to `float`, But Test First
291
291
292
-
Depending on the situation and the compiler's ability to optimize, one may be faster over the other. Choosing `float` will result in lower precision and may be slower due to conversions. On vectorizable operations `float` may be faster if you are able to sacrifice precision.
292
+
Depending on the situation and the compiler's ability to optimize, one may be faster over the other. Choosing `float` will result in lower precision and may be slower due to conversions. On vectorizable operations `float` may be faster if you are able to sacrifice precision.
293
293
294
294
`double` is the recommended default choice as it is the default type for floating point values in C++.
295
295
296
-
See this [stackoverflow](http://stackoverflow.com/questions/4584637/double-or-float-which-is-faster) discussion for some more information.
296
+
See this [stackoverflow](http://stackoverflow.com/questions/4584637/double-or-float-which-is-faster) discussion for some more information.
297
297
298
298
### Prefer `++i` to `i++`
299
299
... when it is semantically correct. Pre-increment is [faster](http://blog2.emptycrate.com/content/why-i-faster-i-c) than post-increment because it does not require a copy of the object to be made.
@@ -313,7 +313,7 @@ for (int i = 0; i < 15; ++i)
313
313
```
314
314
315
315
Even if many modern compilers will optimize these two loops to the same assembly code, it is still good practice to prefer `++i`. There is absolutely no reason not to and you can never be certain that your code will not pass a compiler that does not optimize this.
316
-
You should be also aware that the compiler will not be able optimize this only for integer types and not necessarily for all iterator or other user defined types.
316
+
You should be also aware that the compiler will not be able optimize this only for integer types and not necessarily for all iterator or other user defined types.
317
317
The bottom line is that it is always easier and recommended to use the pre-increment operator if it is semantically identical to the post-increment operator.
318
318
319
319
### Char is a char, string is a string
@@ -353,4 +353,3 @@ Properly use the already highly optimized components of the vendor provided stan
353
353
#### `in_place_t` And Related
354
354
355
355
Be aware of how to use `in_place_t` and related tags for efficient creation of objects such as `std::tuple`, `std::any` and `std::variant`.
Copy file name to clipboardExpand all lines: 11-Further_Reading.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
## C++
6
6
7
-
*https://github.com/isocpp/CppCoreGuidelines The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++
7
+
*https://github.com/isocpp/CppCoreGuidelines The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++
8
8
*https://www.gitbook.com/book/alexastva/the-ultimate-question-of-programming-refactoring-/details - The Ultimate Question of Programming, Refactoring, and Everything
9
9
*http://llvm.org/docs/CodingStandards.html - LLVM Coding Standards - very well written
Expand your horizons and use other programming languages. Other languages have different constructs and expressions. Learning what else is out there will encourage you to be more creative with your C++ and write cleaner, more expressive code.
0 commit comments