COMTRIBUTING: Prefer C++11/14 coding style

This commit is contained in:
Damien GERARD 2015-07-15 11:55:49 +02:00
parent 8254d32cb4
commit ed0a0a68f2

View File

@ -129,6 +129,30 @@ GOOD:
* Prefer enums for integer constants * Prefer enums for integer constants
* Use initialization with curly braces
GOOD:
```c
MyClass instance{10.4};
```
BAD:
```c
MyClass instance(10.4);
```
* Always use `empty()` for testing if a string is empty or not
GOOD:
```c
if (not string.empty())
...
```
BAD:
```c
if (string != "")
...
```
####NAMING CONVENTIONS ####NAMING CONVENTIONS
@ -195,6 +219,16 @@ BAD:
####BEST PRACTICES ####BEST PRACTICES
* Use C++11/14 whenever it is possible
* Use C++11 member initialization feature whenever it is possible
```c
class Foo
{
int value = 0;
};
```
* Prefer this form : * Prefer this form :
```c ```c
++i ++i
@ -211,6 +245,7 @@ BAD:
be checked. Wherever possible, use a SmartPtr instead of old-school pointers. be checked. Wherever possible, use a SmartPtr instead of old-school pointers.
* Avoid using new if you can use automatic variable. * Avoid using new if you can use automatic variable.
However, avoid `shared_ptr` as much as possible. Prefer `unique_ptr` instead.
* Don't place any "using namespace" directives in headers * Don't place any "using namespace" directives in headers