aboutsummaryrefslogtreecommitdiff
path: root/contributing.md
diff options
context:
space:
mode:
authormax-001 <maxsmits21@kpnmail.nl>2024-11-24 11:58:23 +0100
committermax-001 <maxsmits21@kpnmail.nl>2024-11-24 11:58:23 +0100
commitf235743e60fd183319d3cdfb103318739ecbb1e9 (patch)
tree30817cbc4977f6ffc7951268cb6696e408480b5f /contributing.md
parentb1caa74439b404e4b3fe911836004dd7cb47dd50 (diff)
parent1499363d85abedbdb571e33801b821f4dfabc638 (diff)
Merge remote-tracking branch 'origin/master' into max/ecs
Diffstat (limited to 'contributing.md')
-rw-r--r--contributing.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/contributing.md b/contributing.md
index 77a2908..0a90e86 100644
--- a/contributing.md
+++ b/contributing.md
@@ -17,6 +17,7 @@ that you can click on to open them.
working/compiling version of the project
- Pull requests for new code include either automated tests for the new code or
an explanation as to why the code can not (reliably) be tested
+
<!--
- TODO: tagging / versions
-->
@@ -495,6 +496,12 @@ that you can click on to open them.
</td></tr></table></details>
- <details><summary>
Ensure const-correctness
+
+ > [!IMPORTANT]
+ > C-style APIs that work on (possibly internal) references to structs can be
+ > called from const member functions in C++. If the compiler allows you to
+ > mark a function as `const` even though it has side effects, it should
+ > **not** be marked as `const`.
</summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
```cpp
@@ -795,6 +802,23 @@ that you can click on to open them.
```
</td></tr></table></details>
- Do not implement new classes as singletons
+- <details><summary>
+ Retrieving the first or last indices for iterators with a known or expected
+ size should be done using <code>.front()</code> or <code>.back()</code>
+ instead of by index
+ </summary><table><tr><th>Good</th><th>Bad</th></tr><tr><td>
+
+ ```cpp
+ vector<int> foo = { 1, 2, 3 };
+ int bar = foo.first();
+ ```
+ </td><td>
+
+ ```cpp
+ vector<int> foo = { 1, 2, 3 };
+ int bar = foo[0];
+ ```
+ </td></tr></table></details>
## CMakeLists-specific