diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-07 12:23:25 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-07 12:23:25 +0100 |
commit | 89616381251ba892c36bced5f84e91ef8ad6efbe (patch) | |
tree | d2b286fbddd539ffc5e0cfd5a8a96dac93b2a3dd | |
parent | 54f4a322e939dcdb62ab9fbf919bf8cb4b6f7b75 (diff) | |
parent | dc093939558e2d71ad3dd322f1f75dfba893783f (diff) |
Merge branch 'max/code-style' of github.com:lonkaars/crepe
-rw-r--r-- | contributing.md | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/contributing.md b/contributing.md index cd1b6a6..c7f836e 100644 --- a/contributing.md +++ b/contributing.md @@ -541,6 +541,53 @@ that you can click on to open them. #include <crepe/facade/Sound.h> ``` </td></tr></table></details> +- <details><summary> + Ensure exception safety by using RAII classes + </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td> + + ```cpp + std::unique_ptr<Foo> foo = std::make_unique<Foo>(); + ``` + </td><td> + + ```cpp + Foo* foo = new Foo(); + // ... + delete foo; + ``` + </td></tr></table></details> +- <details><summary> + Do not use <code>malloc</code>, <code>calloc</code>, or <code>free</code> (instead use <code>new</code> and <code>delete</code>) + </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td> + + ```cpp + Foo* foo = new Foo(); + delete foo; + ``` + </td><td> + + ```cpp + Foo* foo = (Foo*)malloc(sizeof(Foo)); + free(foo); + ``` + </td></tr></table></details> +- <details><summary> + Prefix member variables with <code>this-></code> + </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td> + + ```cpp + void Foo::set_value(int value) { + this->value = value; + } + ``` + </td><td> + + ```cpp + void Foo::set_value(int value) { + value = value; + } + ``` + </td></tr></table></details> ## CMakeLists-specific |