mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
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.
This commit is contained in:
parent
45117a4134
commit
dd9b8ee7ef
Notes:
sideshowbarker
2024-07-18 17:05:12 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/dd9b8ee7ef5
1 changed files with 17 additions and 2 deletions
|
@ -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;
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue