mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Codingstyle: add comment on "auto".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
9421429cc6
commit
f5659439ba
1 changed files with 21 additions and 1 deletions
|
@ -127,11 +127,31 @@ other editors that implement this coding style, please add them here.
|
|||
## Coding conventions
|
||||
|
||||
* variable declarations
|
||||
in C code we really like them to be at the beginning of a code block,
|
||||
In C code we really like them to be at the beginning of a code block,
|
||||
not interspersed in the middle.
|
||||
in C++ we are a bit less strict about this - but still, try not to go
|
||||
crazy.
|
||||
|
||||
* In C++ code, we generally use explicit types in variable declarations for clarity.
|
||||
Use `auto` sparingly and only in cases where code readability improves.
|
||||
Two classical examples are:
|
||||
- Iterators, whose type names often are verbose:
|
||||
```
|
||||
auto = m_trackers.find(when);
|
||||
```
|
||||
is not only distinctly shorter than
|
||||
```
|
||||
QMap<qint64, gpsTracker>::iterator it = m_trackers.find(when);
|
||||
```
|
||||
it will also continue working if a different data structure is chosen.
|
||||
- If the type is given in the same line anyway. Thus,
|
||||
```
|
||||
auto service = qobject_cast<QLowEnergyService*>(sender());
|
||||
```
|
||||
is easier to read than and conveys the same information as
|
||||
```
|
||||
QLowEnergyService* service = qobject_cast<QLowEnergyService*>(sender());
|
||||
```
|
||||
* text strings
|
||||
The default language of subsurface is US English so please use US English
|
||||
spelling and terminology.
|
||||
|
|
Loading…
Reference in a new issue