Formatting

There are several options one can choose from for code formatting. We opted for the clang-format tool. It can be installed on Linux with:

sudo apt install clang-format

In order to use it, one needs to provide a configuration file that specifies the style conventions, or use one of the predefined style template, e.g. llvm, google, microsoft, etc. In our case, we went for:

clang-format -style=llvm -dump-config > .clang-format

The llvm style seems to match pretty much most of our conventions. The only settings we changed so far are ColumnLimit (i.e. number of characters before a line break), PointerAlignment (i.e. whether pointer and reference symbols are left/middle/right aligned), SpaceAfterTemplateKeyword and AlwaysBreakTemplateDeclarations.

Source files can be formatted with:

clang-format -i *.cpp

and so can files with c++ supported extensions (.c, .h., .hpp, .cu).