diff options
| author | max-001 <maxsmits21@kpnmail.nl> | 2024-11-07 10:10:07 +0100 | 
|---|---|---|
| committer | max-001 <maxsmits21@kpnmail.nl> | 2024-11-07 10:10:07 +0100 | 
| commit | 098ae26d16188b276af77b8bfe9975fcabe8d7f4 (patch) | |
| tree | c17d5fe4d887d94599378f6568445dc6cc35e2e0 | |
| parent | 3a5201961ce31d415042c6273d03e46aed7e6eb8 (diff) | |
Added code styles
| -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 |