aboutsummaryrefslogtreecommitdiff
path: root/contributing.md
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-07 12:44:27 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-07 12:44:27 +0100
commit41c0ea36b025f0c15c7d14db8d88eb9558085b74 (patch)
tree7960787822f4bea96b29af1d81db855edf039759 /contributing.md
parentd7b17796943e2cc09bf4de853a9c1a19d3cb6786 (diff)
parentce8debc03d2ed291285535462cbf4411bf298278 (diff)
Merge remote-tracking branch 'origin/master' into max/big-cleanup
Diffstat (limited to 'contributing.md')
-rw-r--r--contributing.md98
1 files changed, 96 insertions, 2 deletions
diff --git a/contributing.md b/contributing.md
index cd1b6a6..ba8ad68 100644
--- a/contributing.md
+++ b/contributing.md
@@ -78,8 +78,8 @@ that you can click on to open them.
}
```
</td></tr></table></details>
-- Header includes are split into paragraphs separated by a blank line. The
- order is:
+- Header includes (at the top of files) are split into paragraphs separated by
+ a blank line. The order is:
1. system headers (using `<`brackets`>`)
2. relative headers NOT in the same folder as the current file
3. relative headers in the same folder as the current file
@@ -112,6 +112,52 @@ that you can click on to open them.
```
</td></tr></table></details>
- <details><summary>
+ If there is one, the matching template header (<code>.hpp</code>) is included
+ at the bottom of the regular header (<code>.h</code>)
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ Foo.h:
+ ```cpp
+ #pragma once
+
+ template <typename T>
+ void foo();
+
+ #include "Foo.hpp"
+ ```
+
+ Foo.hpp:
+ ```cpp
+ #pragma once
+ #include "Foo.h"
+
+ template <typename T>
+ void foo() {
+ // ...
+ }
+ ```
+ </td><td>
+
+ Foo.h:
+ ```cpp
+ #pragma once
+
+ template <typename T>
+ void foo();
+ ```
+
+ Foo.hpp:
+ ```cpp
+ #pragma once
+ #include "Foo.h"
+
+ template <typename T>
+ void foo() {
+ // ...
+ }
+ ```
+ </td></tr></table></details>
+- <details><summary>
<code>using namespace</code> may not be used in header files (.h, .hpp), only
in source files (.cpp).
</summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
@@ -541,6 +587,54 @@ 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
+ auto foo = std::make_unique<Foo>();
+ ```
+ </td><td>
+
+ ```cpp
+ Foo* foo = new Foo();
+ // ...
+ delete foo;
+ ```
+ </td></tr></table></details>
+- <details><summary>
+ Do not use C-style memory management APIs (<code>malloc</code>,
+ <code>calloc</code>, <code>free</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 all class members 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 new_value) {
+ value = new_value;
+ }
+ ```
+ </td></tr></table></details>
## CMakeLists-specific