diff options
-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 |