This is the style guide for the cpp-netlib project. We strive
for consistency throughout the codebase to make it easier for
developers and users to understand the code.
The style guide is not exhaustive and is subject to change
based on community agreement. If you have questions or
clarifications to the contents of the style guide, get involved
in the discussion at https://groups.google.com/group/cpp-netlib.
We enforce the formatting rules prescribed by the Google Style
Guide as implemented by the clang-format tool.
- Spaces vs Tabs
- Use spaces instead of tab characters.
- Block indents two spaces, arguments to function calls indent 4 spaces from the start of the function name.
- Namespaces do not start indent contexts.
- Curly braces should be on the same line as function, namespace, class, enum, and loop declarations.
- There should be no spaces before and after opening and closing parentheses.
- There should be a space after every comma.
We follow naming conventions used by the standard library.
- Types should be named as nouns, are in all-lowercase characters, and have words separated by underscores.
- Template Parameters
- Template parameter names should be general nouns, should start with an uppercase character, and have words concatenated each starting with uppercase characters.
- Functions should be verbs, are in all-lowercase characters, and have words separated by underscores.
- Macros should be all-uppercase characters, start with
NETWORK and have words separated by underscores.
We use all the facilities afforded us by C++. In particular, the most current C++ standard is the one we code against.
We organize the whole library in namespaces, and where appropriate as macro's and static class members.
- Prefer constants be defined as static class members, function-local static variables, enum classes, scoped enums, then macro's in that order.
- Parts of the implementation considered as "implementation details" shall live in a nested namespace called