aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-07 10:10:07 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-07 10:10:07 +0100
commit098ae26d16188b276af77b8bfe9975fcabe8d7f4 (patch)
treec17d5fe4d887d94599378f6568445dc6cc35e2e0
parent3a5201961ce31d415042c6273d03e46aed7e6eb8 (diff)
Added code styles
-rw-r--r--contributing.md47
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