mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-02 01:44:26 +00:00
Update coding guidelines
Add ranged-based for loop example Add class inheritance example Add Prefer pre-increment, pre-decrement operators section Fix space after comment keyword Fix header include order [skip ci]
This commit is contained in:
parent
c6dfdf9135
commit
71844e13af
@ -231,8 +231,8 @@ Example:
|
||||
|
||||
#include <libtorrent/version.hpp>
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/bittorrent/infohash.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/string.h"
|
||||
@ -282,20 +282,32 @@ auto spinBox = static_cast<QSpinBox*>(sender());
|
||||
// we know the variable type based on the right-hand expression
|
||||
```
|
||||
|
||||
* Space around operations eg `a = b + c` or `a=b+c`:
|
||||
|
||||
Before and after the assignment and other binary (and ternary) operators there should be a space.<br/>
|
||||
There should not be a space between increment/decrement and its operand.<br/>
|
||||
Some valid use cases:
|
||||
* Notice the spaces in the following specific situations:
|
||||
```c++
|
||||
// Before and after the assignment and other binary (and ternary) operators there should be a space
|
||||
// There should not be a space between increment/decrement and its operand
|
||||
a += 20;
|
||||
a = (b <= MAX_B ? b : MAX_B);
|
||||
++a;
|
||||
b--;
|
||||
--b;
|
||||
|
||||
for (int a = 0; a < b; ++b) {
|
||||
// code
|
||||
}
|
||||
|
||||
// Range-based for loop, spaces before and after the colon
|
||||
for (auto i : container) {
|
||||
}
|
||||
|
||||
// Derived class, spaces before and after the colon
|
||||
class Derived : public Base
|
||||
{
|
||||
};
|
||||
```
|
||||
|
||||
* Prefer pre-increment, pre-decrement operators
|
||||
```c++
|
||||
++i, --j; // Yes
|
||||
i++, j--; // No
|
||||
```
|
||||
|
||||
* private/public/protected must not be indented
|
||||
|
Loading…
x
Reference in New Issue
Block a user