diff options
| author | Stefan Boberg <[email protected]> | 2022-04-05 17:22:17 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-04-05 17:22:17 +0200 |
| commit | 9e0e00a9501d2b1e93a4237f313e3a955ccc2152 (patch) | |
| tree | 0dc7e8b2e8b140925125d023d8411262db627274 /docs/cpp-coding/09-Considering_Correctness.md | |
| parent | Update README.md (diff) | |
| download | zen-9e0e00a9501d2b1e93a4237f313e3a955ccc2152.tar.xz zen-9e0e00a9501d2b1e93a4237f313e3a955ccc2152.zip | |
Delete docs directory
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) - - |