diff options
Diffstat (limited to 'docs/cpp-coding/09-Considering_Correctness.md')
| -rw-r--r-- | docs/cpp-coding/09-Considering_Correctness.md | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/docs/cpp-coding/09-Considering_Correctness.md b/docs/cpp-coding/09-Considering_Correctness.md deleted file mode 100644 index 5bc8b61ec..000000000 --- a/docs/cpp-coding/09-Considering_Correctness.md +++ /dev/null @@ -1,30 +0,0 @@ -# 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 - * https://github.com/joboccara/NamedType - -Note that stronger typing can also allow for more compiler optimizations. - -* [Sorting in C vs C++](Sorting in C vs C++.pdf) - - |