Commit 1290c7c0 authored by Dominik Charousset's avatar Dominik Charousset

Add new rule regarding `explicit` to style guide

parent a6774468
...@@ -227,8 +227,8 @@ General rules ...@@ -227,8 +227,8 @@ General rules
even for bodies consiting only of a single statement. even for bodies consiting only of a single statement.
- Opening braces belong to the same line: - Opening braces belong to the same line:
```cpp
```cpp
if (my_condition) { if (my_condition) {
my_fun(); my_fun();
} else { } else {
...@@ -238,8 +238,8 @@ General rules ...@@ -238,8 +238,8 @@ General rules
- Use standard order for readability: C standard libraries, C++ standard - Use standard order for readability: C standard libraries, C++ standard
libraries, other libraries, (your) CAF headers: libraries, other libraries, (your) CAF headers:
```cpp
```cpp
#include <sys/types.h> #include <sys/types.h>
#include <vector> #include <vector>
...@@ -254,6 +254,7 @@ General rules ...@@ -254,6 +254,7 @@ General rules
- Never use C-style casts. - Never use C-style casts.
- Protect single-argument constructors with `explicit` to avoid implicit conversions.
Naming Naming
------ ------
...@@ -274,8 +275,8 @@ Naming ...@@ -274,8 +275,8 @@ Naming
- Template parameter names use CamelCase. - Template parameter names use CamelCase.
- Getter and setter use the name of the member without the `m_` prefix: - Getter and setter use the name of the member without the `m_` prefix:
```cpp
```cpp
class some_fun { class some_fun {
public: public:
// ... // ...
...@@ -293,8 +294,8 @@ Naming ...@@ -293,8 +294,8 @@ Naming
- Use `T` for generic, unconstrained template parameters and `x` - Use `T` for generic, unconstrained template parameters and `x`
for generic function arguments. Suffix both with `s` for for generic function arguments. Suffix both with `s` for
template parameter packs: template parameter packs:
```cpp
```cpp
template <class... Ts> template <class... Ts>
void print(const Ts&... xs) { void print(const Ts&... xs) {
// ... // ...
...@@ -334,8 +335,8 @@ Breaking Statements ...@@ -334,8 +335,8 @@ Breaking Statements
- Break constructor initializers after the comma, use four spaces for - Break constructor initializers after the comma, use four spaces for
indentation, and place each initializer on its own line (unless you don't indentation, and place each initializer on its own line (unless you don't
need to break at all): need to break at all):
```cpp
```cpp
my_class::my_class() my_class::my_class()
: my_base_class(some_function()), : my_base_class(some_function()),
m_greeting("Hello there! This is my_class!"), m_greeting("Hello there! This is my_class!"),
...@@ -348,8 +349,8 @@ Breaking Statements ...@@ -348,8 +349,8 @@ Breaking Statements
``` ```
- Break function arguments after the comma for both declaration and invocation: - Break function arguments after the comma for both declaration and invocation:
```cpp
```cpp
intptr_t channel::compare(const abstract_channel* lhs, intptr_t channel::compare(const abstract_channel* lhs,
const abstract_channel* rhs) { const abstract_channel* rhs) {
// ... // ...
...@@ -357,8 +358,8 @@ Breaking Statements ...@@ -357,8 +358,8 @@ Breaking Statements
``` ```
- Break before tenary operators and before binary operators: - Break before tenary operators and before binary operators:
```cpp
```cpp
if (today_is_a_sunny_day() if (today_is_a_sunny_day()
&& it_is_not_too_hot_to_go_swimming()) { && it_is_not_too_hot_to_go_swimming()) {
// ... // ...
...@@ -385,8 +386,8 @@ extra rules for formatting metaprogramming code. ...@@ -385,8 +386,8 @@ extra rules for formatting metaprogramming code.
- Use one level of indentation per "open" template and place the closing `>`, - Use one level of indentation per "open" template and place the closing `>`,
`>::type` or `>::value` on its own line. For example: `>::type` or `>::value` on its own line. For example:
```cpp
```cpp
using optional_result_type = using optional_result_type =
typename std::conditional< typename std::conditional<
std::is_same<result_type, void>::value, std::is_same<result_type, void>::value,
...@@ -405,8 +406,8 @@ extra rules for formatting metaprogramming code. ...@@ -405,8 +406,8 @@ extra rules for formatting metaprogramming code.
- Note that this is not necessary when simply defining a type alias. - Note that this is not necessary when simply defining a type alias.
When dealing with "ordinary" templates, indenting based on the position of When dealing with "ordinary" templates, indenting based on the position of
the opening `<` is ok, e.g.: the opening `<` is ok, e.g.:
```cpp
```cpp
using response_handle_type = response_handle<Subtype, message, using response_handle_type = response_handle<Subtype, message,
ResponseHandleTag>; ResponseHandleTag>;
``` ```
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment