We chose to abide by the following coding style rules.
- Names representing classes must be in camel case:
MyClass
- Variable and method names must be in lower case, using underscores to separate words:
my_variable
,my_method()
- Names of protected and private members must start with an underscore:
_my_private_member
,_my_private_method()
- File names must be in lower case, using underscores to separate words.
A file which contains a class
MyClass
should be namedmy_class.hpp
- File structure mirrors namespace structure.
For instance
gen::MyClass
is in the filegen/my_class.hpp
- Named constants (including enumeration values) must be placed in the
cst
namespace within the current namespace
namespace cst {
static constexpr int a_number = 3529;
}
- Getters should have the name of the attribute:
this->_objs
should be accessed usingthis->objs()
- Setters should start with "set_" followed by the name of the attribute:
set_objs(const std::vector& ov)
- The public section should be the first section of a class
- Type names defined using typedefs/aliases should end with "_t":
iterator_t
We also follow the coding style rules enforced by clang-format
and a custom configuration. See the format_code repository and software to follow this standard.