summaryrefslogtreecommitdiff
path: root/Documentation
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-06-01 08:54:31 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-01 08:55:47 +0200
commitdd9b8ee7ef5666b0ba257a40c7c024628f821448 (patch)
treed3e06e287a4cc9f9b948d1d98db6b4e9f3b77004 /Documentation
parent45117a4134757989ef39df1ee7471946c57ec09d (diff)
downloadserenity-dd9b8ee7ef5666b0ba257a40c7c024628f821448.zip
Documentation: Add rule about "east const" to CodingStyle.md
Unfortunately we cannot enforce this with clang-format yet, as that feature is not available. Until then, let's try to write new code with this in mind, and convert old code as we go.
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/CodingStyle.md19
1 files changed, 17 insertions, 2 deletions
diff --git a/Documentation/CodingStyle.md b/Documentation/CodingStyle.md
index 5c8271ff94..8e12d9d7e9 100644
--- a/Documentation/CodingStyle.md
+++ b/Documentation/CodingStyle.md
@@ -396,7 +396,7 @@ struct Thingy {
class Doohickey {
public:
- const String& name() const { return m_name; }
+ String const& name() const { return m_name; }
int frob_count() const { return m_frob_count; }
void jam();
@@ -421,7 +421,7 @@ private:
class Doohickey {
public:
- const String& name() const { return this->name; }
+ String const& name() const { return this->name; }
void jam();
@@ -583,3 +583,18 @@ public:
}
```
+### Const placement
+
+[](#east-const) Use "east const" style where `const` is written on the right side of the type being qualified. See [this article](https://mariusbancila.ro/blog/2018/11/23/join-the-east-const-revolution/) for more information about east const.
+
+###### Right:
+
+```cpp
+Salt const& m_salt;
+```
+
+###### Wrong:
+
+```cpp
+const Salt& m_salt;
+```