diff --git a/00-Table_of_Contents.md b/00-Table_of_Contents.md index 2246a46..67008eb 100644 --- a/00-Table_of_Contents.md +++ b/00-Table_of_Contents.md @@ -7,8 +7,9 @@ 6. [Considering Portability](06-Considering_Portability.md) 7. [Considering Threadability](07-Considering_Threadability.md) 8. [Considering Performance](08-Considering_Performance.md) - 9. [Enable Scripting](09-Enable_Scripting.md) - 10. [Further Reading](10-Further_Reading.md) - 11. [Final Thoughts](11-Final_Thoughts.md) + 9. [Considering Correctness](09-Considering_Correctness.md) + 10. [Enable Scripting](10-Enable_Scripting.md) + 11. [Further Reading](11-Further_Reading.md) + 12. [Final Thoughts](12-Final_Thoughts.md) diff --git a/02-Use_the_Tools_Available.md b/02-Use_the_Tools_Available.md index ca456ab..ec104e4 100644 --- a/02-Use_the_Tools_Available.md +++ b/02-Use_the_Tools_Available.md @@ -47,7 +47,7 @@ Package management is an important topic in C++, with currently no clear winner. * [qpm](https://www.qpm.io/) - Package manager for Qt * [build2](https://build2.org/) - cargo-like package management for C++ * [Buckaroo](https://buckaroo.pm) - Truly decentralized cross-platform dependency manager for C/C++ and more - * [vcpkg](https://github.com/microsoft/vcpkg) - Microsoft cross-platform library manager, could be used with CMake + * [Vcpkg](https://github.com/microsoft/vcpkg) - Microsoft C++ Library Manager for Windows, Linux, and MacOS ## Continuous Integration @@ -304,6 +304,15 @@ Both of these tools use coverage reporting to find new code execution paths and * [LibFuzzer](http://llvm.org/docs/LibFuzzer.html) * [KLEE](http://klee.github.io/) - Can be used to fuzz individual functions +### Mutation Testers + +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. + + * [Dextool Mutate](https://github.com/joakim-brannstrom/dextool/tree/master/plugin/mutate) + * [MuCPP](https://neptuno.uca.es/redmine/projects/mucpp-mutation-tool/wiki) + * [mull](https://github.com/mull-project/mull) + * [CCMutator](https://github.com/markus-kusano/CCMutator) + ### Control Flow Guard 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. diff --git a/03-Style.md b/03-Style.md index 277640a..241f5c7 100644 --- a/03-Style.md +++ b/03-Style.md @@ -453,5 +453,5 @@ The Rule of Zero states that you do not provide any of the functions that the co The goal is to let the compiler provide optimal versions that are automatically maintained when more member variables are added. -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. +[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. diff --git a/08-Considering_Performance.md b/08-Considering_Performance.md index 89404c5..784ca33 100644 --- a/08-Considering_Performance.md +++ b/08-Considering_Performance.md @@ -33,6 +33,8 @@ template class MyTemplatedType; This is a proactive approach to reduce compilation time and rebuilding dependencies. +*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.* + ### Avoid Unnecessary Template Instantiations Templates are not free to instantiate. Instantiating many templates, or templates with more code than necessary increases compiled code size and build time. diff --git a/09-Considering_Correctness.md b/09-Considering_Correctness.md new file mode 100644 index 0000000..a9b9c8b --- /dev/null +++ b/09-Considering_Correctness.md @@ -0,0 +1,30 @@ +# Considering Correctness + +## Avoid Typeless Interfaces + + +Bad Idea: + +```cpp +std::string find_file(const std::string &base, const std::string &pattern); +``` + +Better Idea: + +```cpp +std::filesystem::path find_file(const std::filesystem::path &base, const std::regex &pattern); +``` + +The above is better but still suffers from having implicit conversions from `std::string` to `std::filesystem::path` and back. + +Consider using a typesafe library like + + * https://foonathan.net/type_safe/ + * https://github.com/rollbear/strong_type + +Note that stronger typing can also allow for more compiler optimizations. + + +* [Sorting in C vs C++](Sorting in C vs C++.pdf) + + diff --git a/09-Enable_Scripting.md b/10-Enable_Scripting.md similarity index 100% rename from 09-Enable_Scripting.md rename to 10-Enable_Scripting.md diff --git a/10-Further_Reading.md b/11-Further_Reading.md similarity index 100% rename from 10-Further_Reading.md rename to 11-Further_Reading.md diff --git a/11-Final_Thoughts.md b/12-Final_Thoughts.md similarity index 100% rename from 11-Final_Thoughts.md rename to 12-Final_Thoughts.md diff --git a/SUMMARY.md b/SUMMARY.md index a0d963c..8fbe59d 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -8,7 +8,8 @@ * [Considering Portability](06-Considering_Portability.md) * [Considering Threadability](07-Considering_Threadability.md) * [Considering Performance](08-Considering_Performance.md) -* [Enable Scripting](09-Enable_Scripting.md) -* [Further Reading](10-Further_Reading.md) -* [Final Thoughts](11-Final_Thoughts.md) +* [Considering Correctness](09-Considering_Performance.md) +* [Enable Scripting](10-Enable_Scripting.md) +* [Further Reading](11-Further_Reading.md) +* [Final Thoughts](12-Final_Thoughts.md) diff --git a/Sorting in C vs C++.pdf b/Sorting in C vs C++.pdf new file mode 100644 index 0000000..57f782d Binary files /dev/null and b/Sorting in C vs C++.pdf differ