8000 Merge branch 'master' into patch-1 · saharFor/cppbestpractices@4a41888 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a41888

Browse files
authored
Merge branch 'master' into patch-1
2 parents 71aaf01 + 13018f3 commit 4a41888

10 files changed

+51
-8
lines changed

00-Table_of_Contents.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
6. [Considering Portability](06-Considering_Portability.md)
88
7. [Considering Threadability](07-Considering_Threadability.md)
99
8. [Considering Performance](08-Considering_Performance.md)
10-
9. [Enable Scripting](09-Enable_Scripting.md)
11-
10. [Further Reading](10-Further_Reading.md)
12-
11. [Final Thoughts](11-Final_Thoughts.md)
10+
9. [Considering Correctness](09-Considering_Correctness.md)
11+
10. [Enable Scripting](10-Enable_Scripting.md)
12+
11. [Further Reading](11-Further_Reading.md)
13+
12. [Final Thoughts](12-Final_Thoughts.md)
1314

1415

02-Use_the_Tools_Available.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Package management is an important topic in C++, with currently no clear winner.
4747
* [qpm](https://www.qpm.io/) - Package manager for Qt
4848
* [build2](https://build2.org/) - cargo-like package management for C++
4949
* [Buckaroo](https://buckaroo.pm) - Truly decentralized cross-platform dependency manager for C/C++ and more
50-
* [vcpkg](https://github.com/microsoft/vcpkg) - Microsoft cross-platform library manager, could be used with CMake
50+
* [Vcpkg](https://github.com/microsoft/vcpkg) - Microsoft C++ Library Manager for Windows, Linux, and MacOS
5151

5252
## Continuous Integration
5353

@@ -304,6 +304,15 @@ Both of these tools use coverage reporting to find new code execution paths and
304304
* [LibFuzzer](http://llvm.org/docs/LibFuzzer.html)
305305
* [KLEE](http://klee.github.io/) - Can be used to fuzz individual functions
306306

307+
### Mutation Testers
308+
309+
These tools take code executed during unit test runs and mutate the executed code. If the test continues to pass with a mutation in place, then there is likely a flawed test in your suite.
310+
311+
* [Dextool Mutate](https://github.com/joakim-brannstrom/dextool/tree/master/plugin/mutate)
312+
* [MuCPP](https://neptuno.uca.es/redmine/projects/mucpp-mutation-tool/wiki)
313+
* [mull](https://github.com/mull-project/mull)
314+
* [CCMutator](https://github.com/markus-kusano/CCMutator)
315+
307316
### Control Flow Guard
308317

309318
MSVC's [Control Flow Guard](https://msdn.microsoft.com/en-us/library/windows/desktop/mt637065%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396) adds high performance runtime security checks.

03-Style.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,5 +453,5 @@ The Rule of Zero states that you do not provide any of the functions that the co
453453

454454
The goal is to let the compiler provide optimal versions that are automatically maintained when more member variables are added.
455455

456-
The [original article](https://rmf.io/cxx11/rule-of-zero) provides the background, while a [follow up article](http://www.nirfriedman.com/2015/06/27/cpp-rule-of-zero/) explains techniques for implementing nearly 100% of the time.
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.
457457

08-Considering_Performance.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ template<typename T> class MyTemplatedType;
3333

3434
This is a proactive approach to reduce compilation time and rebuilding dependencies.
3535

36+
*Note: forward declaration does prevent more inlining and optimizations. It's recommended to use Link Time Optimization or Link Time Code Generation for release builds.*
37+
3638
### Avoid Unnecessary Template Instantiations
3739

3840
Templates are not free to instantiate. Instantiating many templates, or templates with more code than necessary increases compiled code size and build time.

09-Considering_Correctness.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Considering Correctness
2+
3+
## Avoid Typeless Interfaces
4+
5+
6+
Bad Idea:
7+
8+
```cpp
9+
std::string find_file(const std::string &base, const std::string &pattern);
10+
```
11+
12+
Better Idea:
13+
14+
```cpp
15+
std::filesystem::path find_file(const std::filesystem::path &base, const std::regex &pattern);
16+
```
17+
18+
The above is better but still suffers from having implicit conversions from `std::string` to `std::filesystem::path` and back.
19+
20+
Consider using a typesafe library like
21+
22+
* https://foonathan.net/type_safe/
23+
* https://github.com/rollbear/strong_type
24+
25+
Note that stronger typing can also allow for more compiler optimizations.
26+
27+
28+
* [Sorting in C vs C++](Sorting in C vs C++.pdf)
29+
30+
File renamed without changes.
File renamed without changes.
File renamed without changes.

SUMMARY.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
* [Considering Portability](06-Considering_Portability.md)
99
* [Considering Threadability](07-Considering_Threadability.md)
1010
* [Considering Performance](08-Considering_Performance.md)
11-
* [Enable Scripting](09-Enable_Scripting.md)
12-
* [Further Reading](10-Further_Reading.md)
13-
* [Final Thoughts](11-Final_Thoughts.md)
11+
* [Considering Correctness](09-Considering_Performance.md)
12+
* [Enable Scripting](10-Enable_Scripting.md)
13+
* [Further Reading](11-Further_Reading.md)
14+
* [Final Thoughts](12-Final_Thoughts.md)
1415

Sorting in C vs C++.pdf

929 KB
Binary file not shown.

0 commit comments

Comments
 (0)
0